[OpenLayers-Users] Control with dynamic icon

Oussama Mubarak oussama.mubarak at hyptique.fr
Wed Feb 3 12:10:59 EST 2010


I managed to do what I needed using the jQuery.Rule plugin 
(http://flesler.blogspot.com/2007/11/jqueryrule.html), which allowed me 
to add css rules dynamically for each of my controls.

Oussama Mubarak a écrit :
> Hello,
>
> I am trying to create a panel with a list of controls created 
> dynamically.
>
> I created a custom control class based on OpenLayers.Control.Point to 
> allow me to define default attributes and styles to each point created 
> with this control, by replacing the following line:
> var feature = new OpenLayers.Feature.Vector(geometry);
>
> with the following:
> this.featureAttributes = this.featureAttributes || {};
> this.featureStyle = this.featureStyle || {};
> var feature = new OpenLayers.Feature.Vector(geometry, 
> this.featureAttributes, this.featureStyle);
>
> I did that essentially because I needed to allow the addition of icons 
> associated with the control. So that when a certain control is active, 
> all points created on the map will have its styles.externalGraphic 
> modified. (I didn't want to use the Marker class as the ability to 
> drag and drop is not implemented)
>
> This works great so far.
>
> I am now trying to give each control a different look. Say I have for 
> example a control that allows me to add boys on the map, and another 
> one allows me to add girls. I want to add the boy icon to the first 
> control, and the girl icon to the second, without using the 
> "displayClass" property, as the list of controls is dynamic, so no css 
> rules can be created in advance!
>
> Any help would be greatly appreciated.
>
> Best,
>

-- 
Oussama Mubarak
Développeur web et nouveaux médias
http://semiaddict.com // 06 83 65 76 90




More information about the Users mailing list