[OpenLayers-Users] addUniqueValueRules and selection circles
Jelmer Baas
Baas at speerit.nl
Wed Oct 14 16:18:44 EDT 2009
Hello list,
First of all, I apologize for sending this message again. After numerous
experiments, I still haven't found a solution for my styleMap problem.
The only thing I actually want is after inserting a new feature into a
layer, to give that feature some style properties. Somehow I find it
hard to believe I need to fiddle with stylemaps, a bunch of styles, etc
to achieve that.
I expected this:
controls.polygon.events.register("featureadded",'' , roadFeatureAdded);
function roadFeatureAdded(object){
object.style.strokeColor='red';
}
At any rate, does anyone why my edit circles won't show up (see below),
or how I can achieve what I described in the fasted way possible?
Regards,
Jelmer Baas
> 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