[OpenLayers-Dev] Creating shadowed or stroked and filled lines

fredarters fredarters at gmail.com
Mon Nov 23 16:40:33 EST 2009

I am drawing lines on openlayers for a project.  Using a prior map client I
would draw a line with a 1px black border around a 2px colored line using a
stroke and fill values.  

However, in openlayers the fill values for the style of a line are only used
for polygons, not lines.  I attempted to achieve the same effect by drawing
two separate lines on the same path, a black line 4px wide and a color line
2px wide.  For some reason, only the 2px color line shows up on the map.  If
I pause the rendering between the two lines, they both render but as soon as
I zoom or pan the map the first (4px black) line dissapears and only the
second 2px color line remains rendered.  

Any idea why that might be happening or have a better idea how to achieve
that effect?  

I am doing something like this:

        // first line
        var lineBg = new OpenLayers.Geometry.LineString(points);

        var theStyleBg =  {
            strokeColor: '#000000',
            strokeWidth: 4,
            strokeLinecap: 'round'

        var featureBg = new OpenLayers.Feature.Vector(lineBg, null,
        featureBg.id = 'linebg';

        // second line
        var line = new OpenLayers.Geometry.LineString(points);

        var theStyle =  {
            strokeColor: '#eedd00',
            strokeWidth: 2,
            strokeLinecap: 'round'

        var feature = new OpenLayers.Feature.Vector(line, null, theStyle);
        feature.id = 'line';

View this message in context: http://n2.nabble.com/Creating-shadowed-or-stroked-and-filled-lines-tp4054199p4054199.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.

More information about the Dev mailing list