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?
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?
Share Improve this question edited Sep 4, 2013 at 10:23 Brotheryura asked Sep 4, 2013 at 8:36 BrotheryuraBrotheryura 1,18814 silver badges21 bronze badges2 Answers
Reset to default 5As 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);