问题
I have a sqlite database with about 100 000 rows containing longitudes and latitudes of ATMs. I want to display this ATMs by pins on MKMapView. But I think that it is not good for memory and not o fast if I will load all coordinates from DB at once. What is the best way to do it?
回答1:
You're absolutely right, don't load them all at once!
Use a bounding box to only get coordinates that are within the map your want to display. Check out the answer to this question : Core Data and Core Location
Use the same concept of a upper and lower limit to your lat and lng to only return rows from sqlite that are currently visible. Your query would look something like
SELECT * FROM atms WHERE lat > 51.4 and lat < 51.6 and lng > -0.165 and lng < -0.175
This query only returns ATMs that are near central London (51.5, -0.17).
来源:https://stackoverflow.com/questions/7104178/mapkit-coordinates-from-sqlite-database