Need Help on Implementing marker moving animation by updating latitude and longitude of the location like UBER in web (javascript). I used below code but the marker won't rotate when using car as marker.
var lat;
var lng;
function initialize() {
console.log("Google Maps Initialized")
map = new google.maps.Map(document.getElementById('map-canvas'), {
zoom: 15,
center: {lat: lat, lng : lng, alt: 0}
});
map_marker = new google.maps.Marker({position: {lat: lat, lng: lng}, map: map,icon:"car.png"});
map_marker.setMap(map);
}
// moves the marker and center of map
function redraw() {
map.setCenter({lat: lat, lng : lng, alt: 0})
map_marker.setPosition({lat: lat, lng : lng, alt: 0});
pushCoordToArray(lat, lng);
var lineCoordinatesPath = new google.maps.Polyline({
path: lineCoordinatesArray,
geodesic: true,
strokeColor: '#2E10FF',
strokeOpacity: 1.0,
strokeWeight: 2
});
lineCoordinatesPath.setMap(map);
}
function pushCoordToArray(latIn, lngIn) {
lineCoordinatesArray.push(new google.maps.LatLng(latIn, lngIn));
}
function updateMarker()
{
lat="some latitude";
lng="some longitude";
redraw();
}
Aucun commentaire:
Enregistrer un commentaire