I am looking to add a listener to fire when the user finished drawing the polygon via Google Maps' Drawing Manager. That is when the first point of the polygon intersepts with itself.
Does anyone have experience doing that?
Currently my drawing manager is set up the following way:
handleCreate() {
const { google } = this.props;
const { maps } = google;
const drawingManager = new maps.drawing.DrawingManager({
drawingMode: google.maps.drawing.OverlayType.POLYGON,
drawingControl: false,
polygonOptions: { ...EDITABLE_YARD_BOUNDS_STYLE },
});
drawingManager.setMap(this.map);
}
it's possible by using 'polygoncomplete' listener, like so:
maps.event.addListener(drawingManager, 'polygoncomplete', function(polygon) {
console.log("new polygon is", polygon);
});