var bermudaTriangle = new google.maps.Polygon({
paths: [
new google.maps.LatLng(25.774, -80.190),
new google.maps.LatLng(18.466, -66.118),
new google.maps.LatLng(32.321, -64.757)
]
});
google.maps.event.addListener(map, 'click', function(event) {
console.log(google.maps.geometry.poly.containsLocation(event.latLng, bermudaTriangle));
});
var bermudaTriangle = new google.maps.Polygon({
paths: [
new google.maps.LatLng(25.774, -80.190),
new google.maps.LatLng(18.466, -66.118),
new google.maps.LatLng(32.321, -64.757)
]
});
google.maps.event.addListener(map, 'click', function(event) {
console.log(google.maps.geometry.poly.containsLocation(event.latLng, bermudaTriangle));
});
发布评论
评论(2)
Google 已经提供了一个
https://developers.google.com/maps/documentation/javascript /geometry#containsLocation
Google provides one already
https://developers.google.com/maps/documentation/javascript/geometry#containsLocation
是的,这是可能的。请参阅此函数: http://github.com/tparkin/Google-Maps-Point多边形内
Yes it is possible. See this function: http://github.com/tparkin/Google-Maps-Point-in-Polygon