[OpenLayers-Users] Different renderIntents when features have different styles?

Jeff Dege jeff.dege at korterra.com
Fri Apr 29 17:31:50 EDT 2011


My problem is that I can only apply a StyleMap to a layer, and I need a different appearance for each feature.

It looks, though, as if using a parameterized StyleMap, as the example shows, should work.  

I can the same StyleMap for all features, but have individual settings within it (strokecolor, fillcolor, etc.) determined by attributes on each feature.

Thanks.

-----Original Message-----
From: andreas.hocevar at gmail.com [mailto:andreas.hocevar at gmail.com] On Behalf Of Andreas Hocevar
Sent: Friday, April 29, 2011 3:32 AM
To: Jeff Dege
Cc: openlayers-users at lists.osgeo.org
Subject: Re: [OpenLayers-Users] Different renderIntents when features have different styles?

Hi,

If feature.style is set, it will always take precedence over layer styles. To achieve what you want, create a stylemap with a "default"
and a "select" renderIntent. See
http://openlayers.org/dev/examples/styles-rotation.html for an example that does this.

Andreas.

On Wed, Apr 27, 2011 at 6:37 PM, Jeff Dege <jeff.dege at korterra.com> wrote:
> I have a map with a vector layer.
>
>
>
> On that layer I am drawing a number of features.
>
>
>
> I want those features to have different appearances, so I am setting 
> the style attribute on each.
>
>
>
> I have a SelectControl, with which I am selecting features on the map.  
> I want the selected features to have a different appearance than the 
> unselected features.  But I'm having problems with this.
>
>
>
> Inside Vector.drawFeature(), regardless of what renderIntent I have 
> set on the feature, or what my layer's styleMap may have, if the 
> feature has a style assigned, it looks like it's that style that is 
> used to render the feature, no matter what.
>
>
>
> I can set a StyleMap on the vector layer, so I can have selected 
> features drawn differently than unselected features, but this is 
> ignored if I set a style on the feature, itself.
>
>
>
> Any ideas on how I can get different features to draw on the same 
> layer, with different appearances, and still have their appearances 
> change when the user selects one?
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
>



--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.


More information about the Users mailing list