Google地图Android - 设置太多标记 [英] Google Maps Android - set too many markers

查看:226
本文介绍了Google地图Android - 设置太多标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是,在Android程序的谷歌地图上设置多个标记的最佳方法是什么?


  1. 例如,在当前位置周围添加所有标记1公里

  2. 获取移动地图和显示标记之间的经度和纬度范围

如何获取经度和纬度范围?

解决方案

基于上述评论,您需要执行以下操作:



1)使用 Google Api地图Android参考资料,以确定地图上的可见区域,并确定您的积分是否在确定的区域内。 2 b)仔细地删除添加到地图但不再需要的点。 (IE用户移动了地图)。在这一点上要小心,不要在地图更新完成之前删除一个点,因为用户可能会点击某个点并导致应用程序崩溃。



3)决定你如果用户放大了图像,那么您需要执行以下任一操作:



a)不显示任何内容,让用户反馈放大为点。
b)使用一种算法来绘制一个点的平均点。
c)显示与b相同的标记,但居中区域的点数在该区域。



我会建议大量关于堆栈的研究关于以前的问题,因为已经详细介绍了这个主题。



对于c)已经有了一个很好的iOS实现,它现在是一个待售库,然而现在库的名字让我感到遗憾。



我无法表达您需要确保您的地图操作是异步完成的,谨慎行事或陷入大量陷阱。


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?

解决方案

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.

这篇关于Google地图Android - 设置太多标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆