The marker just does not rotate, why?? I am using Google Maps Api V3 I am using a setInterval because my car is moving along the map And needs to face the direction of the route (for now bearing is just pre set).
var marker = new google.maps.Marker({
icon: {
url: "../includes/images/car.png",
scale: 1,
rotation: 0
},
map: map,
position: overview_path[0],
optimized: false
});
var counter = 1;
setInterval(function() {
debugger;
var bearing = counter * 15;
marker.setPosition(overview_path[counter]);
var icon = marker.getIcon();
icon.rotation = bearing;
marker.setIcon(icon);
setTimeout(function(){
map.panTo({
lat: marker.getPosition().lat(),
lng: marker.getPosition().lng()
})
}, 2000)
counter++;
}, 1000