I am trying to rotate marker icon image but rotation angle doesn't seem to have any effect on the orientation of the icon image.
I found that giving svg path instead of image for marker would make the rotation work like intended.
But is there any way to make rotation work when using image?
jsfiddle of the issue
function updateMap(bearing) {
// var bearing = 135;
console.log(bearing);
var icon = marker.getIcon();
icon.rotation = bearing;
marker.setIcon(icon);
console.log(marker);
}
function initialize() {
initMap({ Latitude:37.4419, Longitude: -122.1419});
}
You can't do this when you provide a URL for the image like that.
From the docs:
" If a string is provided, it is treated as though it were an Icon with the string as url."
And the Icon class hasn't got a rotate
method. Only Symbol lets you do this.
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