How to add and remove google-maps marker in javascript?

3

How to add a bookmark in google maps and delete when you keep selected for 5 seconds?

  function genera_marcador(lat, lng) {
        var marcador = new google.maps.Marker({
            position: new google.maps.LatLng(lat, lng),
            draggable: true,
            map: map,
            animation: google.maps.Animation.DROP
        });
    };
    
asked by German Steven Vera Amaya 03.03.2017 в 02:08
source

1 answer

0

Google maps does not have a global store of the features you draw on the map. It is up to you to keep that reference. For example if you return the marker that you create

function genera_marker (lat,lng) {
    ...
    return marcador;
}

And you declare it as

var mimarker = genera_marker (10,10);

Then you can delete it with

mimarker.setMap ( null );

The same goes for circles, polygons, rectangles and polylines.

    
answered by 03.03.2017 / 02:22
source