0
votes

Assuming I have a database of POI with their respective coordinates (longitude & latitude). What would be the "standard" way to display the POI as annotations around the user's current location? To elaborate:

  • Given a zoom level, I guess I have to search through the database for all POI whose distance to the current location < a certain threshold, then create annotations for them. Or is there any smarter way?
  • If the user zooms in/out, moves the map... I will need to redo the whole thing again?
  • It seems that MapKit has a mechanism to cache/reuse annotations. Should I create a lot of them right away and let MapKit decides what to render when the visible region changes? I guess this would make the transition smoother, but also consumes more memory. What is your experience with this?

Thanks.

1

1 Answers

1
votes

Actually, relying on the distance between the current location and the POIs is not the right approach : evaluating distances takes time, you'd better just rely on the region displayed by your map (property region) and check which of your POIs are contained in this region.

When zooming in / out, the region changes, so you may have to redo the same.

See my answer here : MKMapView loading all annotation views at once (including those that are outside the current rect)

This guy is trying to use the caching of annotations and my answer may help you in your case.

To check if your POI is the displayed region, I posted a piece of code that may help here : iPhone Development - Is Pin Annotation in a viewable Map Region