I have a table in the SQLite database with 4,000 locations, including latitude and longitude. Based on information from the region provided by MKCoordinateRegion class, how can I get the places that are located in this region from the map? Is It Possible?
First I tried using Haversine formula, but what I did was just sort the places closest to the center of the map. But I want places that are located in a region of the map. Or am I wrong?
Thanks in advance.
You can get the max/min values for latitude and longitude from your
MKMapViewby accessing the region attribute:You can then access the maximum and minimum values as follows:
Hope this helps! If you’re storing your data in Core Data, an
NSSet, or anNSArray, you can then use anNSPredicateto filter out the results that meet the above criteria.Here’s the documentation for your
MKMapViewand anMKCoordinateRegion.