[GIS] Rotating marker in OpenLayers

markersopenlayers-2

I am creating markers using this method :

var markers = new OpenLayers.Layer.Markers( "Markers" );
map.addLayer(markers);
var size = new OpenLayers.Size(21,25);
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
var icon = new OpenLayers.Icon('http://www.openlayers.org/dev/img/marker.png',size,offset);
`enter code here`markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0),icon));

Now , I want to rotate the marker 90 degrees to the left (or right).

How can I do it?

I was able to find example to rotate a feature , but I am not using a feature.
Instead, I am using a marker.

Best Answer

As @dariapra mentioned. Your better off using a vector feature so you can take advantage of the rotation property.

You will find no drawbacks from switching over. You will see that using the more flexible feature vector will be more convenient.

Use the externalGraphic style property to designate the marker image.