In my app i'm adding alot of pins and in viewForAnnotaion I set animatesDrop=TRUE on my MKPinAnnotaionView. The problem is that when having 200+ pins dropping one by one takes a long time. I have seen Apps that drops all pins at once and wonder how to do that.
Let me know if i'm not clear.
Thanks!
What you are doing is not wrong - but you might want to try creating those pins on a secondary thread (your app will be snappier).
Also, you might have operations that are computationally expensive that you might want to move outside the delegate method (i.e. viewForAnnotation).
Finally, you can try closing in on a smaller area, so that your map displays less pins.
I think it is done programmatically by detecting that pins are closest.
You could build differents list of pins depending on the map zoom to display only pins that are separates of x pixels on the screen.
Related
I have a list of 15k I need to display on a MKMapView embedded in my app.
I think this is probably too many to load at once, and I want to check if there is a standard way to do this. The XML file with the informations about the pins is stored on a webserver.
I think I have a few options, but still I'm not sure where the bottleneck would be (network, displaying many pins at once, loading the pins on the map the first time, etc):
Parse the whole xml file and add all the annotations. Force the user zoom so you can't see too many pins together
Parse the whole xml file and add all the annotations. Use a library for grouping the Pins.
Load only the top 50 pins in the area the user is currently in. Everytime the position is updated call a script on the webserver that only serves 50 positions based on map latitude-longitute and zooming.
Cache everything in coredata and do the same as the previous point.
Any considerations about performances I should do? Any other solutions? Will these perform well enough?
Thanks!
The bottleneck will be displaying that many pins at one time on the map. You shouldn't display more than around 500 at one time. Zoomed in might be OK, but zoomed out will affect performance and map visibility.
Here's a library that will do clustering for you:
http://applidium.com/en/news/too_many_pins_on_your_map/
I'm building an iPhone app (in iOS 5) with several different views, one of which contains a map (also has separate view controller). The first time I go over to this view, it takes a while for it to load, and things such as animating pin drops also don't work well as a result of it. Not to mention that it takes a bit for the location to stabilize.
What I want to know is if there's a way to load MKMapView before a user goes to that view, so by the time they get there, these issues aren't present anymore.
I've already seen this and this question but they haven't been very helpful. Keep in mind that I don't really need to interact with that view before I get there, I just want it to be fully loaded by the time I go there.
I want to track my physical Movement through iphone within my office using my office map.The map will show all rooms of my office.for example,if i move from administraion block to another block, i have to move one icon from administraion block to another block on the map.in other words, the icon should move as i move within office.is it possible to do in iphone SDK?any help please?
Can't really see how this can be done, most offices have terrible GPS reception. Thus using GPS is out of the questions, als it will not be precise enough.
You could try using bluetooth although it very limited in iOS and you would have to place bluetooth dongles every wehe.
My guess it can't be done with the precision that you need.
Is there a best practice or common pattern for allowing users to select a precise location on a map using MapKit?
I've seen examples where a user can enter an address in a search box. But what about the case where a user doesn't know the exact address and wants to select a location from the map?
It's a bit more complex task than it seems.
Here is the guide how to detect single taps on a Web View.
I've used the same pattern to detect single taps on Map View but allowing zooming and dragging at the same time.
Hope it helps.
I would say that replicating the Maps application is close to a best practice for map applications.
You can test it for yourself; tap and hold somewhere on the map and a pin that you can move around by dragging will be dropped where you held your finger.
The Google Maps app seems to tackle what is a reasonable idea by touching the map by instead allowing you to drop a pin on the map; the SO post might help out.
Here is the situation:
I am displaying images on the map by using custom annotations. Everything works fine but I would like to improve it visually by resizing the AnnotationView so that it shrinks as the map is zoomed out. I want to do this because, obviously, more annotations fill up the screen and need to be shrunk so that they don't overlap each other too much and the user can see more annotations. (Of course, I would like to enlarge AnnotationViews when the map is zoomed in again).
I have achieved this by removing all annotations from the map and adding them back again, whenever regionDidChangeAnimated is called. However, these images are loaded from the internet, so downloading the images again (since the annotations have been removed) doesn't seem to make sense.
I hope I have explained the situation well, and hope to contribute to SO in the future.
Thanks in advance.
P.S. I'm developing with iOS 4.0
Since you are using iOS 4.0 I would suggest using a class that conforms to the MKOverlay protocol instead of MKAnnotationView. Overlays zoom with the map and will scale appropriately. You can probably use 1 overlay to handle all your annotations. Check out the HazardMap demo Apple provided in the 2010 WWDC talks on http://developer.apple.com
Alternatively, you could use something like the k nearest neighbors algorithm to group annotations per zoom scale. However, that can be kind of slow if you have a lot of annotations. I tried it once with several thousand annotations and did not like the performance hit that was incurred. I think < 1000 annotations might have decent performance with this method though.
It sounds like you're already on the right path and that the only real problem is the downloading of the images. Is there any particular reason you can't cache them by writing them to the documents directory (or the cache directory if you want them to go way when the app quits) when you receive them and look there first before displaying them?