[OpenLayers-Dev] handler style

Alexandre Dube adube at mapgears.com
Thu Jul 23 08:05:57 EDT 2009


jessisena wrote:
> Hi,
> Anybody knows if is possible to have two differents controls Draw feature,
> with the same kind of handler (for example point), and everyone with their
> own style? 
> That is, if I can have two controls that draw points with different styles,
> in the same layer.
> Thanks

You could overwrite the activate and deactivate function of both your 
DrawFeatures control to add a "featureadded" listener to your layer. On 
"activate", register the event. On "deactivate", unregister the event. 
Both events could call a different function to add an attribute to the 
added feature, let's say "type", the first control adds "1" as a value, 
the second "2", then you would need to redraw the feature.

With all this, you could have a addUniqueValueRules to your layer's 
styleMap object to render your features differently, based on your 
"type" attribute.

Does this make sense ?

Alexandre Dubé

More information about the Dev mailing list