Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onChange event for Google Maps APIv3 drawing manager

I'm using the GMaps API v 3 Drawing Manager to let users draw shapes on a map.

I can use the complete events to trigger actions when a shape is added to the map (eg. overlaycomplete or polygoncomplete)-- but I am also allowing the user to edit the completed shapes.

Is there a way to trigger an action when a shape is changed? I can't see any way to fire another function when a shape is modified.

like image 664
user101289 Avatar asked Jan 31 '13 17:01

user101289


1 Answers

List of editing events can be found here:

Editable events

Dragging events

Here is an example how to use it with DrawingManager when a circle's radius has changed:

google.maps.event.addListener(drawingManager, 'circlecomplete', function (circle) {
  google.maps.event.addListener(circle, 'radius_changed', function () {
    console.log('radius changed');
  });
});

http://jsfiddle.net/Vvk4d/

You can use the same approach for polygons/rectangles.

like image 62
dimusic Avatar answered Sep 21 '22 03:09

dimusic