[OpenLayers-Users] Copying the style in a StyleMap into
eachfeature?
Arnd Wippermann
arnd.wippermann at web.de
Sat Mar 20 15:52:02 EDT 2010
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: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von Nick Whitelegg
Gesendet: Samstag, 20. März 2010 16:47
An: users at openlayers.org
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
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
More information about the Users
mailing list