[OpenLayers-Users] Copying the style in a StyleMap into each
feature?
Nick Whitelegg
Nick.Whitelegg at solent.ac.uk
Sat Mar 20 11:46:59 EDT 2010
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
More information about the Users
mailing list