[OpenLayers-Users] addUniqueValueRules and selection circles
Jelmer Baas
Baas at speerit.nl
Tue Oct 13 10:42:51 EDT 2009
Dear List,
I'm stuck with the addUniqueValueRules function and editable geometry.
Basicly, I wanted to be able to color different polygons, which I do now
by :
controls.polygon.events.register("featureadded",'' , roadFeatureAdded);
function roadFeatureAdded(object){
var t = document.getElementById("objectType");
object.feature.attributes.objType=t.options[t.selectedIndex].value;
vectors.redraw();
}
Since I couldn't find any way to do a object.strokeColor='green' (or
something similar), I've been using the addUniqueValueRules option. My
current code (excuse the mess, I've been testing a lot of different
options):
var oStyleMap = new OpenLayers.StyleMap(
{
"default":OpenLayers.Util.applyDefaults(
{
fillColor: 'black',
fillOpacity: 0.4,
strokeColor: 'black',
strokeWidth: 2,
pointRadius: 8,
radius: 8
}
,OpenLayers.Feature.Vector.style["default"])
, "select": OpenLayers.Util.applyDefaults({pointRadius: 8,
fillOpacity: 0.4,
strokeColor: "#ff0000",
strokeWidth: 2},OpenLayers.Feature.Vector.style["default"])
});
oStyleMap.addUniqueValueRules("default", "objType", lookup);
vectors = new OpenLayers.Layer.Vector("Vector Layer",{styleMap:
oStyleMap});
The coloring works properly like this, but when trying to select an
object, the resize/edit circles don't appear. Any idea what I'm missing?
I'm sure it's something simple...
With kind regards,
Jelmer Baas
More information about the Users
mailing list