[OpenLayers-Dev] Creating shadowed or stroked and filled lines
fredarters
fredarters at gmail.com
Tue Nov 24 10:25:35 EST 2009
Thanks for the suggestion Eric. Turns out it was the shared style. I said
that i was doing "something like this" for the code sample I posted.. turns
out in my code I was using one style object rather than two. Once I
separated them the styles were correctly applied and I have my "shadowed"
line.
Thanks!
Eric Lemoine-2-2 wrote:
>
> On Monday, November 23, 2009, fredarters <fredarters at gmail.com> wrote:
>>
>> 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,
>> theStyleBg);
>> featureBg.id = 'linebg';
>> this.pathLayer.addFeatures([featurebg]);
>>
>> // 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';
>> this.pathLayer.addFeatures([feature]);
>
>
> Hi. Your lines share the same point objects, this might be the problem.
>
> Cheers,
>
> --
> 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
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
>
>
--
View this message in context: http://n2.nabble.com/Creating-shadowed-or-stroked-and-filled-lines-tp4054199p4058494.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.
More information about the Dev
mailing list