[OpenLayers-Dev] Style for a GML/WFS layer

Christopher Schmidt crschmidt at metacarta.com
Sat Mar 31 08:46:01 EDT 2007


On Sat, Mar 31, 2007 at 02:44:18PM +0200, Andreas Hocevar wrote:
> On 3/31/07, Christopher Schmidt <crschmidt at metacarta.com> wrote:
> >On Sat, Mar 31, 2007 at 10:19:36AM +0200, Andreas Hocevar wrote:
> >> How can I tell a vector layer (GML/WFS) which style it should use for
> >> rendering every feature?
> >
> >There is a patch for this functionality on
> >http://trac.openlayers.org/ticket/543 , awaiting review.
> >
> >So the answer is probably 'wait a couple days' ;)
> 
> Great to hear that! Meanwhile I did an ugly workaround. I added a
> style option to the layer, and then I added this event handler:
> 
> layer.onFeatureInsert=function(feature) {
> 	feature.style = feature.layer.options.style;
> 	feature.layer.renderer.drawGeometry(feature.geometry, feature.style);
> }
> 
> This has the disadvantage that every feature is drawn twice when the
> GML is laoding, so the preFeatureInsert event handler from the patch
> would be the perfect solution!

Well, it's a slightly different solution, since the functionality you
added to onFeatureInsert is (in the latter patch) built in by default.
The patch you made is not really so much a workaround -- I've just
integrated it into the core instead of doing it from outside :)

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Dev mailing list