Rotate function programmatically Open layers

TL; DR I want to rotate a feature in my open layers.
I want it to collide with a specific header that I am getting from the server.


I know that you can make the function rotate at a point or so:

window.setInterval(function() {rotateFeature(
       pointFeature, 360 / 20, origin)}, 100);

      

as from the example of open layers.

But I want to be able to look at it towards the title that is given to me, therefore.

  • Can I view the function in the header?
  • Can I meet a function (image) in the same way?
  • If not, is it possible to automatically calculate the required rotation and place it that way?
  • Or any ideas on how I can do this with an image? (hoping not to have 360 ​​images).
Example: e.g. D

Thanks in advance.


No luck yet:

      window.setInterval(function() {rotateFeature(
        imagefeature, 150 / 360, origin)}, 1000);
        function rotateFeature(feature, angle, origin) {
            feature.geometry.rotate(angle, origin);
            }

      

Where origin is the center of gravity of the image object.

Any piece of code?

+2


a source to share


1 answer


You can use images / icons to represent vector points eg.

http://openlayers.org/dev/examples/vector-features.html

Uses this png file alt text http://openlayers.org/dev/img/marker.png Then you can rotate point like in another example. You can rotate at any angle:

http://dev.openlayers.org/releases/OpenLayers-2.8/doc/apidocs/files/OpenLayers/Geometry/Point-js.html#OpenLayers.Geometry.Point.rotate



rotate: function(angle,origin)

      

Rotate a point around another. Parameters

angle {Float} Angle of rotation in degrees (measured counterclockwise from the positive x-axis)

origin {OpenLayers.Geometry.Point} Center point for rotation

+3


a source







All Articles