Javascript Google Maps JS API v3计算返回NaN之间的距离,而不是距离
我知道这里也有类似的问题,但似乎背景不一样 问题如标题-Javascript Google Maps JS API v3计算返回NaN之间的距离,而不是距离,javascript,google-maps,google-maps-api-3,Javascript,Google Maps,Google Maps Api 3,我知道这里也有类似的问题,但似乎背景不一样 问题如标题-google.maps.geometry.spheremic.ComputedDistanceBeweenmethod返回NaN而不是距离中所述。 相关代码很简单: var location = new google.maps.LatLng(mapCons.mapStore[i].latitude, mapCons.mapStore[i].longitude); var distance = google.m
google.maps.geometry.spheremic.ComputedDistanceBeween
method返回NaN而不是距离中所述。
相关代码很简单:
var location = new google.maps.LatLng(mapCons.mapStore[i].latitude, mapCons.mapStore[i].longitude);
var distance = google.maps.geometry.spherical.computeDistanceBetween(centerLatLng, location);
if(distance < distanceLimit){
parsedMarkers.push(markers[i]);
}
console.log(distance)
var location=new google.maps.LatLng(mapCons.mapStore[i].纬度,mapCons.mapStore[i].经度);
var distance=google.maps.geometry.Spheremic.ComputedDistanceBetween(中心距,位置);
if(距离<距离限制){
push(markers[i]);
}
控制台日志(距离)
我三次检查,centerLatLng
和location
都是有效的google.maps.LatLng
对象。
导入的谷歌地图js API V3
库不包含所需的库”https://maps.googleapis.com/maps/api/js?v=3.exp&key=*****************&库=几何图形,位置“
原因可能是什么?检查了所有返回方法的对象
.lat()
,但没有检查.lng()
我的代码
经度中有一个输入错误,我三次检查了-因此,在代码的前两行之间添加控制台。log(location,centerLatLng)
显示两个google latlng对象?在分配位置
变量后-是,对。同样对于.lat()
,.lng()
在加载页面或运行代码时返回正确的值控制台中没有任何错误?我检查过了,看起来你做的是对的。请提供一个例子来说明这个问题,对我来说,发布的代码是有效的(如果我输入正确的话)。如果我将google.maps.LatLngLiteral
用于centerLatLng
(这将是一个问题),我会得到一个javascript错误Uncaught TypeError:a.lat不是一个函数
,并且console.log
没有运行。我检查的地方没有包含一个版本。。。i、 e.nov=3.exp
我也没有指定库(刚刚得到所有库)