Google maps 如何使用谷歌地图几何库中的ContainesLocation。
我正在尝试使用Google geometry库中的Google maps 如何使用谷歌地图几何库中的ContainesLocation。,google-maps,google-maps-api-3,Google Maps,Google Maps Api 3,我正在尝试使用Google geometry库中的containsLocation,但无法让它工作 var point = new google.maps.LatLng(51.331, 3.538); var poly = [ new google.maps.LatLng(51.401818509550615, 3.547626782103622), new google.maps.LatLng(51.397574277049365, 3.563607598960424), new goo
containsLocation
,但无法让它工作
var point = new google.maps.LatLng(51.331, 3.538);
var poly = [
new google.maps.LatLng(51.401818509550615, 3.547626782103622),
new google.maps.LatLng(51.397574277049365, 3.563607598960424),
new google.maps.LatLng(51.398540111384975, 3.567880788749134),
... // it is a lot bigger
];
if(google.maps.geometry.poly.containsLocation(point, poly) == true) {
alert("yes");
}
Javascript控制台给出了一个错误,但它指向了Google的lib中的一个函数。所以我认为问题应该出在这个函数的某个地方。好了,愚蠢的我
我错误地将所有坐标用作数组,我必须使用创建的多边形对象
var polyOptions = {
...
}
draw = new google.maps.Polygon(polyOptions);
draw.setMap(map);
if(google.maps.geometry.poly.containsLocation(point, draw) == true) {
alert("yes");
}
我也有同样的问题,
([object object])
,我可以解决这样创建多边形变量的问题:
draw=new google.maps.Polygon({path:polyOptions})代码>
然后问题消失了。当我这样做时,我得到了错误对象[Object Object]没有方法“get”
我不确定,但我相信这是针对API版本2的。那时候真的很管用。。。