Search code examples
jquerygoogle-mapsjquery-gmap3

Geofence in gmap3


I want to add a geofence in gmap3. I thought the most basic way would be to draw a circle and check if the marker is within the bounds of the circle, when the marker is added.

I added a circle

var fence = $('#dispatcher').gmap3(
  { action: 'addCircle',
    circle:{
      options:{
        center: [53.99212, -1.541812],
        radius : 3000,
        fillColor : "#FFAF9F",
        strokeColor : "#FF512F" 
      }
    }
  }
);

Any idea how would I get the bounds to check against?


Solution

  • Maybe using

    circle.getBounds();
    

    it's listed here Google maps V3 API, then using contains(latLng:LatLng)