Return to Snippet

Revision: 46378
at May 18, 2011 07:33 by marzsman


Initial Code
google.maps.event.addListener(map, 'click', addPoint);

function addPoint(event) { 
    var marker = new google.maps.Marker({
        position: event.latLng,
        map: map,
        draggable: true
    });
    markers.push(marker);
    google.maps.event.addListener(marker, 'click', function() {
        marker.setMap(null);
        for (var i = 0, I = markers.length; i < I && markers[i] != marker; ++i);
        markers.splice(i, 1);
    });
    google.maps.event.addListener(marker, 'dragend', function() {
        
    });
}

Initial URL

                                

Initial Description
Add draggable markers on a Google map with a click, remove marker on click

Initial Title
Add marker Google maps on click

Initial Tags
google

Initial Language
JavaScript