MapKit:来自Sqlite数据库的坐标 [英] MapKit: coordinates from Sqlite database
问题描述
我有一个sqlite数据库,其中约有10万行,其中包含ATM的经度和纬度.我想通过MKMapView上的图钉显示此ATM.但是我认为如果一次从DB加载所有坐标,则对内存不利,而且速度也不快.最好的方法是什么?
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?
推荐答案
您绝对正确,不要一次全部加载它们!
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
使用相同的上限和下限上限概念来仅返回来自sqlite的当前可见行.您的查询类似于
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
此查询仅返回位于伦敦市中心(51.5,-0.17)附近的ATM.
This query only returns ATMs that are near central London (51.5, -0.17).
这篇关于MapKit:来自Sqlite数据库的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!