MapKit: coordinates from Sqlite database

為{幸葍}努か 提交于 2019-12-08 09:38:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!