问题描述
我目前正在为Android开发一个应用程序,它使用谷歌地图服务。因为用户将能够看到数千个标记我想只加载那些目前在地图范围内(即当用户看特定地图瓦片)。我知道如何用JavaScript / HTML做到这一点。然而,Android的似乎并没有提供任何类似的方法,如containsLatLng(经纬度)或的getBounds(我只找到getLatitudeSpan和getLongitudeSpan,但不知道我该如何使用它们,以达到同样的效果)。
I'm currently developing an app for Android which uses google map service. Because users will be able to see thousands of markers I would like to load only those which are currently within the map bounds (i.e. when user look at specific map tile). I know how to do it with javascript/html. However, Android doesn't seem to provide any similar methods such as containsLatLng(latlng) or getBounds (I only found getLatitudeSpan and getLongitudeSpan, but don't know how can I use them in order to achieve the similar effect).
任何人都可以给我一些提示?我将非常AP preciate任何帮助或至少指向自己在正确的方向。
Can anyone give me some hint on that? I would greatly appreciate any help or at least pointing myself in the right direction.
推荐答案
您可以使用getMapCenter,只是加上或减去纬度跨度或经度跨度(2当然分)来找到边界。
You could use getMapCenter and just add or subtract the latitude span or longitude span (divided by 2 of course) to find the bounds.
这篇关于如何动态地加载标记在谷歌Android,地图当前位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!