【问题标题】:Check whether or not a point is in a polygon (Google Maps API)检查点是否在多边形中(Google Maps API)
【发布时间】:2010-10-15 15:21:46
【问题描述】:

所以我有一张地图here

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

提前致谢。

【问题讨论】:

    标签: api google-maps polygon point-in-polygon


    【解决方案1】:

    Google 已经提供了一个

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

    https://developers.google.com/maps/documentation/javascript/geometry#containsLocation

    【讨论】:

      【解决方案2】:

      是的,这是可能的。看到这个函数:http://github.com/tparkin/Google-Maps-Point-in-Polygon

      【讨论】:

        猜你喜欢
        • 2013-12-03
        • 2017-05-03
        • 2011-09-25
        • 1970-01-01
        • 2018-07-13
        • 2012-11-23
        • 2013-06-19
        • 1970-01-01
        • 2014-08-26
        相关资源
        最近更新 更多