找到所有的标记给定半径内有的、半径、标记

2023-09-11 00:29:56 作者:平凡的向日葵

输入:给定一个特定的坐标(纬度和经度)和半径 输出:显示所有驻留在从标记给出列表圈子标记

Input: Given a specific co-ordinate (latitude and longitude) and radius Output: Displaying all the markers which reside under that circle from given list of markers.

我怎样才能做到这一点在谷歌地图?

How can I do this in google maps?

推荐答案

只是遍历所有你必须​​标记和使用下面的函数来获得具体的坐标来标记的距离: computeDistanceBetween ()

Just iterate all the markers you have and use the following function to get the distance from the specific co-ordinate to the marker: computeDistanceBetween():

要计算这个距离,调用computeDistanceBetween(),它传递   2 LatLng对象。

To compute this distance, call computeDistanceBetween(), passing it two LatLng objects.

我发现它在这里。然后,只需过滤掉一切变成是足够接近的标志。

I found it over here. Then just filter out all the markers that turn out to be close enough.