-2

I have a polygon which is editable so when i start to edit it it shows small icon on it.
Below in picture an arrow icon (for undo changes).

enter image description here

so i want to add another icon by my own so user can delete that polygon by clicking on it. So ho to add icon there?

Update Here is what i do so far Link Now i just want to add icon when polygon complete event fired.

1
  • @duncan i update a question. I have only problem that how to add some icon when polygon complete
    – Blu
    Sep 18, 2014 at 13:09

1 Answer 1

1

So you've already got the event listener for when the polygon is complete.

What you could do is add a marker in the middle of your polygon, with a custom icon that looks similar or identical to the 'undo' icon Google are using.

google.maps.event.addListener(drawingManager, 'polygoncomplete', function(polygon) {
    drawingManager.setDrawingMode(google.maps.drawing.OverlayType.FALSE);

    // find out the paths of this polygon
    var path = polygon.getPath();

    var bounds = new google.maps.LatLngBounds();

    for (var i = 0; i < path.length; i++) {
        bounds.extend(path.getAt(i));
    }

    var centre = bounds.getCenter();

    // add a marker here:
    var marker = new google.maps.Marker({
        position: centre,
        map: map,
        icon: 'https://google-developers.appspot.com/maps/documentation/javascript/examples/full/images/beachflag.png'
    });
});
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.