如何在Google地图几何库中使用containsLocation。 [英] How to use containsLocation in Google maps geometry library.
本文介绍了如何在Google地图几何库中使用containsLocation。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用Google几何库中的 containsLocation
,但无法使其正常工作...
I am trying to use the containsLocation
from the Google geometry library, but can't get it to work...
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函数。所以我认为这个问题应该在这个函数的某个地方。
The Javascript console gives an error, but that points to a function in Google's lib. So I assume the problem should lie somewhere in this function.
推荐答案
Oke,stupid me
Oke, stupid me
我错误地将所有的坐标作为数组使用,我不得不使用创建的多边形对象。
I was wrong using all the coords as an array, I had to use the created polygon object.
var polyOptions = {
...
}
draw = new google.maps.Polygon(polyOptions);
draw.setMap(map);
if(google.maps.geometry.poly.containsLocation(point, draw) == true) {
alert("yes");
}
这篇关于如何在Google地图几何库中使用containsLocation。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文