[OpenLayers-Users] StyleMap and Select style issues

ashley_c_mort ashley_c_mort at raytheon.com
Tue Feb 16 22:52:02 EST 2010


	I am having trouble getting the 'Select' style to work the way I
need (when using the ModifyFeature control).  I have two issues:

1) The vertices in the Select style always use the externalGraphic image
from the 'default' style.  It seems that setting extendDefault:false on the
StyleMap behaves properly for all styles except externalGraphic/graphicName.
How can I display a separate graphic for my regular point features and the
vertex point features (when I'm using the ModifyFeature control)?

2) I'm using styleMap.addUniqueValueRules to show/hide features.  When I use
addUniqueValueRules code in there, my vertex point graphics (during
ModifyFeature) don't show up at all.  Is there a better way to control
visibility of features when using a StyleMap?

Any ideas are appreciated!

 
var defaultModified = OpenLayers.Util.applyDefaults({
"externalGraphic":"../common/img/geoLoc.png"}, 
OpenLayers.Feature.Vector.style["default"]);

var selectModified = OpenLayers.Util.applyDefaults({ 
"graphicName":"circle",
"fillColor":"white",
"strokeColor":"red", 
"strokeWidth":5 
}, OpenLayers.Feature.Vector.style["select"]); 

var defaultStyle= new OpenLayers.Style(defaultModified); 

var selectStyle= new OpenLayers.Style(selectModified); 

var customStyleMap = new OpenLayers.StyleMap({
"default": defaultStyle, 
"select": selectStyle
},{"extendDefault":false});

var displayLookup={
'on':{display:"block"},
'off':{display:"none"}
};

customStyleMap.addUniqueValueRules("default", "display", displayLookup); 

var layer=new OpenLayers.Layer.Vector(name, 
{ styleMap: customStyleMap });
            
map.addLayer(layer);





More information about the Users mailing list