Detect if marker is within circle overlay on Google Maps (Javascript API V3)

前端 未结 2 639
名媛妹妹
名媛妹妹 2020-12-08 05:18

I have markers dotted around a map, and a radius (circle overlay) on a marker marking your location (which changes every time you move). Is there any way I can check to see

2条回答
  •  庸人自扰
    2020-12-08 05:52

    google.maps.Circle.prototype.contains = function(latLng) {
      return this.getBounds().contains(latLng) && google.maps.geometry.spherical.computeDistanceBetween(this.getCenter(), latLng) <= this.getRadius();
    }
    

提交回复
热议问题