[OpenLayers-Dev] SelectStyle
Paul Spencer
pspencer at dmsolutions.ca
Tue Oct 6 21:52:15 EDT 2009
I *think* what you should do is something like this (note that this
code may not work but the concept should be right):
var defaultStyle = new OpenLayers.Style({fillColor: 'orange',
fillOpacity: 0.3, strokeWidth: 1.0, strokeColor: 'orange',
pointRadius: 10 });
var selectStyle = new OpenLayers.Style({fillColor: 'blue',
fillOpacity: 0.3, strokeWidth: 1.0, strokeColor: 'blue', pointRadius:
10});
var anotherStyleMap = new OpenLayers.StyleMap({
'default': defaultStyle,
'select': selectStyle
});
The StyleMap can have multiple styles for different render intents.
Default is used by ... er ... default :) Select is default used for
selections.
The select control's selectStyle is expected to be the name of a
renderIntent, i.e. 'select'.
In theory, you should be able to create an entirely new renderIntent
by giving it a different name when creating the StyleMap but in
practice this hasn't worked well for me and I have dug into why that
is yet.
Cheers
Paul
On 2009-10-06, at 4:50 PM, Francesca Facchetti wrote:
> Hi,
> I'm trying to apply a style do my SelectFeature control, but it
> doesn't work.
>
> this is the style I want for unselected features:
> var anotherStyleMap = new OpenLayers.StyleMap({fillColor: 'orange',
> fillOpacity: 0.3, strokeWidth: 1.0, strokeColor: 'orange',
> pointRadius: 10 });
>
> this is my layer:
> punti = new OpenLayers.Layer.WFS("Postgis, punti",
> "featureserver.cgi/punti?format=WFS",
>
> {maxfeatures: maxf_level},
>
> {extractAttributes: true, displayInLayerSwitcher: false, styleMap :
> anotherStyleMap}
>
> );
>
>
> this is the style for selected features:
> var stileSelezione = new OpenLayers.Style({fillColor: 'blue',
> fillOpacity: 0.3, strokeWidth: 1.0, strokeColor: 'blue', pointRadius:
> 10});
>
> and this is the SelectFeature control:
> modify_POI_info: new OpenLayers.Control.SelectFeature(punti, {
> clickout: true, toggle: false, multiple: false, hover: false,
> box: false, selectStyle: stileSelezione
> })
>
> the first style is applied, but the selectStyle isn't. What do I do
> wrong?
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
__________________________________________
Paul Spencer
Chief Technology Officer
DM Solutions Group Inc
http://research.dmsolutions.ca/
More information about the Dev
mailing list