Hi, Instead of apply a style to each feature, you can try to use a styleMap with context for your layer. In your moveFeature function you set an attribute with the value of the rotation and the styleMap set the rotation property for the feature automatically (after drawFeature) by this attribute.
Arnd -----Ursprüngliche Nachricht----- Von: [email protected] [mailto:[email protected]] Im Auftrag von Nick Whitelegg Gesendet: Samstag, 20. März 2010 16:47 An: [email protected] Betreff: [OpenLayers-Users] Copying the style in a StyleMap into eachfeature? I'm developing an application which shows a GeoRSS vector layer overlay over an OSM map (see http://www.free-map.org.uk/fe/). I want people to be able to rotate each camera icon which corresponds to a feature from the GeoRSS. I do this by adding a DragFeature control and overriding the moveFeature() method so that the feature is rotated, not moved, on drag. However, to get the camera icon to rotate, I have to re-specify the style already specified in the StyleMap for the layer. This is because loading a StyleMap does not automatically apply a "style" attribute to each feature. e.g.: moveFeature: function(pixel) { if (!this.feature.style) { this.feature.style = { externalGraphic: 'images/cam.png', graphicHeight: 16, graphicWidth: 16, rotation: 0 }; } this.feature.style.rotation = (this.feature.style.rotation < 350) ? this.feature.style.rotation+10: 0; this.layer.drawFeature(this.feature) } This works, but seems inefficient. Is there any way of telling OL to automatically copy the style for the layer specified in the StyleMap into the "style" attribute of each feature when a layer is loaded? Thanks, Nick _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
