Tuesday, 27 August 2013

Is it possible to cancel a Google Maps API polyline while it's being drawn?

Is it possible to cancel a Google Maps API polyline while it's being drawn?

I've built a Google Maps API toolset that allows the user to draw shapes
over the map, give them names and record areas. On the completion of each
shape, they are prompted to give it a name and set a few other options
such as whether or not to show a label on the map.
I'd like to give the user the option to right click and cancel a polyline
(or polygon) whilst placing the points, i.e. while they're drawing it.
Based on what I've read in the documentation, I should be able to detect
that the user right clicked on the map, but I'm not sure how to cancel the
overlay they were drawing, as it won't have been committed to the map yet,
which means I won't be able to refer to it as an object.
Any ideas?

No comments:

Post a Comment