Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to re-drop marker on the google map?

I've got two functions:

function showMarkers() {
    hotspotsIterator = 0;
    for(var i = 0; i < table.length; i++) {
        var obj = table[i];
        if(obj && obj.marker) {
            var obj = table[i];
            obj.marker.setMap(map);
        }
    }
}

function hideMarkers() {
    for(var i = 0; i < table.length; i++) {
        var obj = table[i];
        if(obj && obj.marker) {
            obj.marker.setMap(null);
        }
    }
}

First is showing markers, and second is hiding them. When I first use showMarkers() there is Animation.DROP performed. But when I hide them and show again, animation is not running, and the markers are simply shown.

Can someone tell me how to re-drop markers? Without creating new instances?

EDIT:

I have already created the code to re-create the same marker and it works, but its not elegant solution at all!

And Google Docs for markers doesn't resolve the issue.

like image 630
Karol Avatar asked Nov 05 '22 18:11

Karol


1 Answers

Add following code right below the obj.marker.setMap(map); : obj.marker.setAnimation(google.maps.Animation.DROP);

Here the reference: Marker Animations

like image 196
Yuriy Rozhovetskiy Avatar answered Nov 11 '22 04:11

Yuriy Rozhovetskiy