[OpenLayers-Users] Fill an OpenLayers.Geometry.LinearRing
Jürgen Dankoweit
Juergen.Dankoweit at T-Online.de
Thu Aug 22 10:50:26 PDT 2013
Hello Ruben,
Am 22.08.2013 19:34, schrieb mail.roliveira at gmail.com:
> How can I set the fill and stroke colors of
> a OpenLayers.Geometry.LinearRing
> <http://dev.openlayers.org/docs/files/OpenLayers/Geometry/LinearRing-js.html#OpenLayers.Geometry.LinearRing>?
>
> I tried this way but no success:
>
> var linearRing = new OpenLayers.Geometry.LinearRing(pointArray);
>
> var feature = new OpenLayers.Feature.Vector(linearRing, {}, {fillColor:
> "#00FF00"})
>
> feature is latter added to an OpenLayers.Layer.Vector layer.
>
> Is I set the style of the layer, I can paint the linearRing, but I have
> several linearRings added on the same layer, and I want to have
> individual fill on each one of the linearRings.
In your styleMap-definition you have to define some placeholders. Look here:
var sm = new OpenLayers.StyleMap({
stroke: true,
strokeColor: "\${strokecolor}",
fill: true,
fillColor: "\$fillcolor}
});
layer = new OpenLayers.Layer.Vector("LinearRings", {
styleMap: sm, ...});
You have to use this like in the following example:
var pf = new OpenLayers.Feature.Vector(...);
if (pf) {
pf.attributes = {strokecolor: "#123456", fillcolor: "#654321"};
layer.addFeatures([pf]);
}
Best regards
Juergen
--
Meine stets unfertige Homepage: www.dankoweit.de
More information about the Users
mailing list