Google maps api 3 使用Google Map API从位置数组中检测最近的位置
我有一个位置数组:{'place1,'place2,'place3'}*//这些是地址 现在假设有一个新位置:“place4” 我想检测哪一个最靠近“位置4”……从上面的位置数组进行比较 i、 e.从位置数组中跟踪点的最近位置…(使用谷歌地图API) psuedo代码:Google maps api 3 使用Google Map API从位置数组中检测最近的位置,google-maps-api-3,Google Maps Api 3,我有一个位置数组:{'place1,'place2,'place3'}*//这些是地址 现在假设有一个新位置:“place4” 我想检测哪一个最靠近“位置4”……从上面的位置数组进行比较 i、 e.从位置数组中跟踪点的最近位置…(使用谷歌地图API) psuedo代码: foreach(var item in array) { var i = TrackNearestLocationByGoogleMapAPIs(item); if(i is nerest) {
foreach(var item in array)
{
var i = TrackNearestLocationByGoogleMapAPIs(item);
if(i is nerest)
{
print(i); and go out of loop...
}
}
我不认为谷歌地图API v3提供了一个简单的机制来做到这一点。您可能能够检索每个位置的纬度和经度,并找出与该数据最近的点。没有API调用来执行您想要的操作。你必须自己用哈弗公式计算距离,如下所示: