[OpenLayers-Users] Need help changing fill/stroke colour for a RegularPolygon

Eric Lemoine eric.lemoine at camptocamp.com
Sun Oct 11 02:01:27 EDT 2009


On Sunday, October 11, 2009, noosy <vanessa.towers at dsto.defence.gov.au> wrote:
>
> Hi,
>
> Thanks for the reply, I didn't think there was either but I thought i would
> try it anyway!
>
> You may have noticed I have already got "Polygon" in there but still no
> luck..
>
> Any other suggestions? Surely this must be a straightforward thing?

Hi. This is a known issue. The RegularPolygon handler ignores
layerOptions. See <http://trac.openlayers.org/ticket/2232>.

Cheers,
>
>
>
> Ivan Grcic-2 wrote:
>>
>> Hi, I dont think there is such symbolizer as RegularPolygon, thers
>> only symbolizers for Point, Line and Polygon. So Id try with Polygon.
>>
>> Cheers
>>
>> On Fri, Oct 9, 2009 at 6:01 AM, noosy
>> <vanessa.towers at dsto.defence.gov.au> wrote:
>>>
>>> Hi,
>>>
>>> I have the following code:
>>>
>>> var sketchSymbolizers = {
>>>    "RegularPolygon": {
>>>        strokeWidth: 2,
>>>        strokeOpacity: 1,
>>>        strokeColor: "#666666",
>>>        fillColor: "#cbc7f0",
>>>        fillOpacity: 0.3
>>>    },
>>>    "Point": {
>>>        pointRadius: 4,
>>>        graphicName: "square",
>>>        fillColor: "white",
>>>        fillOpacity: 1,
>>>        strokeWidth: 1,
>>>        strokeOpacity: 1,
>>>        strokeColor: "#666666"
>>>    },
>>>    "Polygon": {
>>>        strokeWidth: 2,
>>>        strokeOpacity: 1,
>>>        strokeColor: "#666666",
>>>        fillColor: "#cbc7f0",
>>>        fillOpacity: 0.3
>>>    }
>>> };
>>>
>>> var style = new OpenLayers.Style();
>>> style.addRules([
>>>    new OpenLayers.Rule({symbolizer: sketchSymbolizers})
>>> ]);
>>>
>>> var sm = new OpenLayers.StyleMap({"default": style});
>>>
>>> var polyOptions = {sides: 40, persist: true, layerOptions: {styleMap:
>>> sm}};
>>>
>>>  var measureCirc = new GeoExt.Action({
>>>        icon: './draw_circle_off.png',
>>>        cls: 'x-btn-icon',
>>>        control: new OpenLayers.Control.Measure(
>>>            OpenLayers.Handler.RegularPolygon, {
>>>               handlerOptions: polyOptions
>>>           }
>>>        ),
>>>        map: mapPanel.map,
>>>        // button options
>>>        toggleGroup: "draw",
>>>        allowDepress: true,
>>>        // check item options
>>>        group: "draw"
>>>    });
>>>
>>> For some reason my circle is still orange :(
>>>
>>> The above code works fine with a OpenLayers.Handler.Polygon so what is
>>> the
>>> problem with the RegularPolygon?
>>>
>>> I have gone into Firebug and modified the following
>>>
>>> measureCirc -> control -> handler -> style -> fillColor -> "cbc7f0"
>>>
>>> ... and the colour changes to purple :) But I don't know how to do this
>>> programmatically as everything I have tried has had no effect. Please
>>> direct
>>> me as to how I can change the colour (so that it remains this colour on
>>> zoom/pan also) so long as the geometry persists.
>>>
>>> --
>>> View this message in context:
>>> http://n2.nabble.com/Need-help-changing-fill-stroke-colour-for-a-RegularPolygon-tp3792284p3792284.html
>>> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>>> _______________________________________________
>>> Users mailing list
>>> Users at openlayers.org
>>> http://openlayers.org/mailman/listinfo/users
>>>
>>
>>
>>
>> --
>> Ivan Grcic
>> ___________________________--
> View this message in context: http://n2.nabble.com/Need-help-changing-fill-stroke-colour-for-a-RegularPolygon-tp3792284p3801930.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com



More information about the Users mailing list