Drawing Manager Object Listeners

2,977 views
Skip to first unread message

Anthony D

unread,
May 23, 2012, 4:54:37 PM5/23/12
to Google Maps JavaScript API v3
Good Evening

When utilizing the Drawing Manager to create a marker, polygon,
circle, or rectangle is there a way to add a listener to each draw
object besides adding a listener to the Draw Manager (var
drawingManager)?

var drawingManager = new google.maps.drawing.DrawingManager({
drawingMode:
google.maps.drawing.OverlayType.CIRCLE,
drawingControl: true,
drawingControlOptions: {
position:
google.maps.ControlPosition.TOP_CENTER,
drawingModes: [

google.maps.drawing.OverlayType.MARKER,

google.maps.drawing.OverlayType.POLYGON,
google.maps.drawing.OverlayType.CIRCLE,
google.maps.drawing.OverlayType.RECTANGLE
]},
markerOptions: {
icon: markOrange,
title: 'intersection'
},
polygonOptions: {
fillColor: '#ff9900',
fillOpacity: .65,
strokeWeight: 5,
clickable: false,
editable: true,
zIndex: 1
},
circleOptions: {
fillColor: '#0000cc',
fillOpacity: .65,
strokeWeight: 5,
clickable: false,
editable: true,
zIndex: 1
},
rectangleOptions: {
fillColor: '#00ff00',
fillOpacity: .65,
strokeWeight: 5,
clickable: false,
editable: true,
zIndex: 1
}
});
drawingManager.setMap(map);

Enoch Lau (Google Employee)

unread,
May 23, 2012, 8:30:30 PM5/23/12
to google-map...@googlegroups.com
If you add listeners to your DrawingManager, you are given handles to the overlays that are drawn: https://developers.google.com/maps/documentation/javascript/reference#DrawingManager

For example, in your markercomplete listener, the event argument is a Marker. You can then add listeners to that marker as you would normally with your own markers.

Enoch
Reply all
Reply to author
Forward
0 new messages