Once I have features with different attributes, the mechanisms you describe 
would work, but I don't have any attributes in my features to distinguish them 
by.

The features are being created by the DrawFeature control.  And it doesn't add 
any attributes to the features it creates. My problem is how to have two 
different instances of the DrawFeature control add different attributes to the 
features they create.

Currently, I've created my own control that adds an attribute to the feature, 
based on an option passed when the control was created, and this is working. 
But it seems a bit kludgy, and is likely to break if a future version of 
OpenLayers makes changes to how DrawFeature.drawFeature() works.  So I was 
wondering if there was a better way to do it.

From: Pierre Giraud [mailto:pierre.gir...@camptocamp.com]
Sent: Tuesday, April 06, 2010 2:46 AM
To: Jeff Dege
Cc: users@openlayers.org
Subject: Re: [OpenLayers-Users] Different types of polygons?

You can add a listener on the "featureadded" event of your vector layer. In 
this listener callback function, you should be able, for example, to set a 
specific value for an attribute of the added feature. Then using a StyleMap on 
your layer you should be able to draw the given feature with a specific color 
depending on the attribute value.

I hope this helps.

Pierre
On Mon, Apr 5, 2010 at 11:26 PM, Jeff Dege 
<jeff.d...@korterra.com<mailto:jeff.d...@korterra.com>> wrote:
I find myself needing to draw two different kinds of polygons on a Vector 
layer.  First, they need to have different colors, and second, they need to be 
processed differently when they are complete.

I'm currently working on the first problem, and am playing around with two 
DrawFeature controls.  Right now, they behave the same.  I'm trying to find a 
way to hook into them, in some way, so I can modify the features they create.

Any ideas?


_______________________________________________
Users mailing list
Users@openlayers.org<mailto:Users@openlayers.org>
http://openlayers.org/mailman/listinfo/users



--
Pierre GIRAUD
Géomaticien, Analyste

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 93
Mail : pierre.gir...@camptocamp.com<mailto:pierre.gir...@camptocamp.com>
http://www.camptocamp.com
_______________________________________________
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users

Reply via email to