With GMaps.js i can add markers easy way:
map.addMarker({
lat: -12.043333,
lng: -77.028333
});
After create that marker, i want to set him a new position after some time. For example my next code:
setInterval(function() {
setNewPosition();
}, 5000);
setNewPosition(){
map.removeMarkers();
map.addMarker({
lat: -13.043333,
lng: -77.028333
});
}
But i don`t want all time a removed marker, i want only set him a new position. That is the really possible? I know in google map it solved with google.maps.LatLng() and .setPosition(), but how in Gmaps.js they used?
As far as I know there is no special method to set the position.
addMarker() returns a native google.maps.Marker, so you may store this marker in a variable and call setPosition() later.
addMarker() return a google.maps.Marker, so call setPosition() function with new google.maps.LatLng
var latlng = new google.maps.LatLng(45.667, 12.239);
marker.setPosition(latlng);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With