Google Maps Android - set too many markers

不羁的心 提交于 2019-12-11 18:56:53

问题


My question is, What is the best way to set to many markers on google maps on android program? I have a sqlite database with longitude and latitude for every markers.

  1. For example add all markers 1km around the current location
  2. Get the range of longitude and latitude on moving map and display markers between that range

How can i get the range of longitude and latitude?


回答1:


Based on the comments from above you will need to do the following:

1) Use the Google Api maps reference for Android to determine the visible area on the map and if one of your points is within the determined area.

2) Carefully remove points added to the map but which are no longer needed. (IE the user has moved the map). Be careful at this point not to remove a point before the map has finished updating, as the user could tap on a point and crash the app.

3) Decide what you're doing about zoom level, if a user zooms right out then you need to do one of the following:

a) Display nothing, give the user feedback to zoom in for points. b) Use an algorithm to plot a point at an average of a point. c) Display a marker as with b but centered in a region with the number of points in that region.

I would advise lots of research on stack regarding previous questions as this topic has been covered in some detail.

For c) there has been a good iOS implementation which is now a for-sale library, however the name of the library escapes me at the moment. I am told the implementation is excellent.

I cannot express enough that you need to make sure your map operations are done asynchronously, be wary of this or fall into lots of traps.



来源:https://stackoverflow.com/questions/8482650/google-maps-android-set-too-many-markers

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