[OpenLayers-Dev] Advanced styles with OpenLayers
Gorka López Rivacoba
gorka.lopez.rivacoba at gmail.com
Tue Mar 3 09:58:40 EST 2009
Hello,
I have a GML layer and I want to asign differents colours to its polygons
(default style). I want to assign a style when the polygons are selected too
(the same style to all the polygons in the layer).
I try to assign a different stylemap to each layer's polygon (not depends on
the features attributes) like in http://trac.openlayers.org/wiki/Styles, but
it seems that OpenLayers.Feature.Vector doesn´t support to asign a mapstyle
(in order than a basic style):
if (...)style = {fillColor: "#FCED97", strokeColor: "#FCE144", fillOpacity:
0.5, strokeWidth: 2};
else if (...)style = {fillColor: "#000000", fillOpacity: 0.1, strokeColor:
"#000000", strokeWidth: 1};
var styleSel = {fillColor: "#FC1797", strokeColor: "#FC1797", fillOpacity:
0.5, strokeWidth: 2};
var myStyleMap = new OpenLayers.StyleMap({"default": style,"select":
styleSel});
var vector = new OpenLayers.Feature.Vector(geometry, record, myStyleMap);
layer.addFeatures(vector);
I try to assign a default style to each polygon and assign the selected
style to the OpenLayers.Layer.GML (it's always the same style), but in this
case the selected style is not shown:
var styleSel = {fillColor: "#FF7474", strokeColor: "#FF0000", fillOpacity:
0.5, strokeWidth: 2};
var myStyleMap = new OpenLayers.StyleMap({"select": styleSel});
layerEditable = new OpenLayers.Layer.GML("Polygons", urlGML,{styleMap:
myStyleMap});
.........................................................................................................................................
if (...)style = {fillColor: "#FCED97", strokeColor: "#FCE144", fillOpacity:
0.5, strokeWidth: 2};
else if (...)style = {fillColor: "#000000", fillOpacity: 0.1, strokeColor:
"#000000", strokeWidth: 1};
var vector = new OpenLayers.Feature.Vector(geometry, record, style);
layer.addFeatures(vector);
Is there a way to assign differents styles in each polygon of a layer and a
selected style to the complete layer?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20090303/bdcc94a8/attachment.html
More information about the Dev
mailing list