Reputation: 5353
TLDR I want to rotate a Feature in my open layers.
I want it to face a certain heading that I am receiving from server.
I know that you can make a feature spin on a point or so on:
window.setInterval(function() {rotateFeature(
pointFeature, 360 / 20, origin)}, 100);
as from the open layers example.
But I want to be able to face it towards a heading I am given, so.
An example or such would be appreciated.
No luck so far using:
window.setInterval(function() {rotateFeature(
imagefeature, 150 / 360, origin)}, 1000);
function rotateFeature(feature, angle, origin) {
feature.geometry.rotate(angle, origin);
}
Where origin is the centeroid of the image object.
Any ideas code side?
Upvotes: 3
Views: 4878
Reputation: 6528
You can use images / icons to represent vector points e.g.
http://openlayers.org/dev/examples/vector-features.html
Uses this png file alt text http://openlayers.org/dev/img/marker.png You should then be able to rotate the point as in the other example. You can rotate to any angle:
rotate: function(angle,origin)
Rotate a point around another. Parameters
angle {Float} Rotation angle in degrees (measured counterclockwise from the positive x-axis)
origin {OpenLayers.Geometry.Point} Center point for the rotation
Upvotes: 3