Google Maps v3 - update handles when dragging and dropping

When I drag my location marker, it needs to update other markers as I work with a radius. Therefore, if I drag my location around, it should remove markers that are outside the radius, and add markers inside the radius. He does this, but he continues to add the same markers as 8 times or so, and of course no one wants it.

google.maps.event.addListener(marker, 'drag', function() {
geocoder.geocode({'latLng': marker.getPosition()}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
        if (results[0]) 
        {
            $('#address').val(results[0].formatted_address);
            ownlat = marker.getPosition().lat();
            ownlng = marker.getPosition().lng();
            clearOverlays(); //deletes old markers
            getevents(); //adds new markers  
        } 
    }   
});             

});

+3
source share
1 answer

The API docs indicate that the drag and drop event fires repeatedly when the marker is dragged. So I decided that he calls getevents()several times in a row.

"dragend", , . ( , getevents ?)

+2

All Articles