Could anyone please tell how to add some specific locations on MapView(MKMapView). I made mapView which shows my current location, I also added searchBar for searching address's locations. For now, this works fine, but I also want for MapView to show me some specific locations (for example: hospitals nearby)
Thanks!
Get the coordinates for the location you want to show on the map. Have an array of annotations with each annotation having the coordinate you want to show. then make use of the method
[urMapView addAnnotations:urAnnotationsArray];
Related
I use MKMapkitView when I move the map location based on the lat,long it's pick the address on the textfield. Now I need to change to Only India based search on the map how to restrict it. any one help me. my code is [dropbox.com/s/rt9rdt3x164ghbo/LocationVC.swift?dl=0][1] any one help me. No idea for me.
I am using CLLocationManager to retrieve current location in my app and display using MapView, i want to slide the map so that the current location should also change to the new location where the map slides and it should annotate to the new location, how to do it? Please give your suggestions with sample code.
You probably don't mean "the current" since that means where the phone actually is, unless you want to transport the phone to another place when using this app which would be quite a feat. So, how about drawing a layer over the top of your map that keeps a pin drawn at the centre so it looks as if the pin is moving over the map, but really the map is moving under the pin.
I am working on the map application and as per requirement i need to show a single pin for a single region even if it has multiple user coordinates when its completely zoomed out but when its zoomed in to the map then i should display all the pins as per its coordinates.
I have given example below to explain my problem.
I have city New York on this city I have 100 pins on my mapview when I am zooming out of my map it should show me only one annotation pin on the place of 100 pins but when I am zooming in then it should show again 100 pin on map.
Does any one knows about this. I need suggestion. Please note that I am getting all the locations from web services except my current location. This should not be affecting application so that application shouldn't become slow.
Please suggest some solution.
The Apple WWDC 2011 video, "Visualizing information geographically with MapKit", https://developer.apple.com/videos/wwdc/2011/
shows how to cluster map annotations - it's exactly what you need.
Of course there is a control for that...
Take a look at OpenClusterMapView, it should be exactly what you need.
There is no API for this.
You will need to manage the pins yourself. As a user zooms in on the map, you will need to decide at what point to remove the aggregated pin and add the individual pins. Inversely, as a user zooms out you will need to remove the individual pins and replace with the aggregated pin.
Might be a good idea to use a custom pin for the aggregated pin to suggest that it represents multiple pins.
I think this link might help you know the current zoom level:
Zoom and Region
Link to a similar question:
Pin Overlap
I would like to add more locations on MapView something similar to this image. In this image there are only 2 pin points, but i need to have more than 10 locations to add in the map. Is this possible ? and is there any tutorial/sample code where i could start on this ?
You need to implement the annotation protocol, which simply requires you to include a couple of fields in an object so the map view knows what to annotate the 'pin' with.
You can then add multiple pins to the map view programatically.
I found this blog post useful when I was doing this.
http://mayurbirari.wordpress.com/2011/02/07/how-to-access-mkmapkit-in-iphone/
It's called MKPinAnnotationView and you can have as many as you want on map.
You need to implement protocol for it and it has pin as default image property.
Background: I have created an application that allows users to submit an entry to an online database, and view other entries from that database. These entries contain geocodes for latitude and longitude which are used for positioning the annotations on the MapKit. Users can submit the location using either their current location or an address, which is then geocoded.
Question: What is the proper or suggested method of handling annotations that fall on the exact same coordinates?
I was thinking of checking if there are any duplicate geocodes in the XML file pulled from the database and creating a single annotation with a custom annotationView that displays all of the separate ones. In addition, I was thinking of checking for duplicates and displaying "Multiple Entries..." and having the detail view display a table view with all of the entries.
Am I on the right track?
I think you are on the right track, you should check for duplicate geocodes and merge them into one. Displaying many annotations with the same location could be confusing because the pins will stack on top of each other and will be hard to diffrentiate and to click one by one.
Are you talking exact same geocode or kinda sorta close? Because if it's exact, then you're on the right track, but if it's +/- delta-T then you may have to come up with a different way of handling them since when zoomed-in all the way each location could be distinct. An easy way to hanle it is to drop or round-off decimal points in the lat/long value based on the zoom factor before checking for coordinate equality.
Other than that it sounds like you're on the right track. You will probably want to do both the custom annotation view (but that could work for only a few items) with the option to move on to a separate table view if there are more items to show.
One other thing I'd add is you could make it so your placemarker shows the number of items that co-reside in that location. You can do this by sticking a text label on top of your custom placemarker view and putting the number in it or by having pre-rendered icons with say, 1-9 and "..." (for more than that) in the heads of the markers. That way the user can quickly see there's more items to look for.