As you see in the following code, the Markers are draggable. In some cases, If a marker is dropped in a wrong area(polygon) I would like to cancel the drop event and consequently the marker come back to its original location automatically.
function placeMarker(latlng, color, isDraggable) {
var marker = new GMarker(latlng, { icon: getIcon(color), draggable: true });
map.addOverlay(marker);
GEvent.addListener(marker, "dragend", function () {
//redraw polygons again
});
GEvent.addListener(marker, "click", function () {
var latlng = marker.getPoint();
map.openInfoWindowHtml(marker.getPoint(), latlng.y + ", " + latlng.x);
});
return marker;
}
The question is how can I cancel the drag event of marker when it's already dropped in dragend
event?