Currently i am working on a Location based application for iPhone/iPad . I have several annotations in my MapKit , what i want to do is to track the location of the user and shows the annotations that are within the 3km . Can somebody give me a start ?
Share
Sorry for the delayed response… the question just fell off my radar.
I’m going to suppose that you have a method that returns a set of NSValue-wrapped
CLLocationCoordinate2Dstructs (the basic approach is the same regardless of what your internal data representations are). You can then filter the list using a method something akin to the following (warning: typed in browser):With the filtered set of coordinates in hand, you can create
MKAnnotationinstances and add them to the map in the usual manner, as described in Apple’s documentation.If you have many thousands of test locations then I suppose this approach could start to incur performance issues. You would then want to switch your point storage approach to use, e.g., quadtrees, to reduce the number of points that need to be precision-filtered. But don’t optimize prematurely!
Hope that helps!