Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
检查点是否位于多边形中(谷歌地图API)_Api_Google Maps_Polygon_Point In Polygon - Fatal编程技术网

检查点是否位于多边形中(谷歌地图API)

检查点是否位于多边形中(谷歌地图API),api,google-maps,polygon,point-in-polygon,Api,Google Maps,Polygon,Point In Polygon,所以我有一张地图 如何使用GoogleMapsAPI检测给定坐标是否在该多边形内?可能吗 提前谢谢。是的,这是可能的。查看此功能:谷歌已经提供了一个 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.m

所以我有一张地图

如何使用GoogleMapsAPI检测给定坐标是否在该多边形内?可能吗


提前谢谢。

是的,这是可能的。查看此功能:

谷歌已经提供了一个

  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));
  });