I'm currently using the DrawingManager
to allow users to draw shapes on the map. Once a shape is drawn, I set up a listener on the polygon's path so I can react after the path has been changed:
var polygonPath = event.overlay.getPath();
google.maps.event.addListener(polygonPath, 'set_at', function () {
// my code...
});
This works great when a user adds a new shape using the drawing tool. However, if I already have polygons in my database that I am displaying with the ui-gmap-polygon
AngularJS directive (from the angular-google-maps
project), how can I listen to the set_at
event since this event is not on the polygon, but is instead, on the polygon's path (MVCArray)?
The only place I was able to find a reference to set_at
in the source code of the angular-google-maps
project was in the array-sync.coffee file, but it doesn't look like it is being exposed.
If I can't listen to the set_at
event directly using the directive, I would hope there is an event that gets triggered when the directive creates the polygon so that I can then get the polygon's path and then add a listener to that, just like the code above.
I have put together a JSFiddle with the basic structure, along with the events object. It currently handles the polygon's mouseover and mouseout, but not the set_at
event.
setAt()
to build your polygons? – Impeccableng-repeat
onui-gmap-polygon
and set the path attribute so the directive can create the polygons. I need to listen to theset_at
event so I can know when the user modifies the polygon so I can react with some custom code. – Spongioblast