[OpenLayers-Users] Overriding map style causing major drift

Christopher Dale chrelad at gmail.com
Fri Aug 21 17:05:36 EDT 2009


Hey everyone,

I'm running into another problem with this way of setting the vector
layer's style. It looks like the editing handles are inheriting the
styles from the vector layer as well, which makes for some nasty
looking handles.

Anyone know of a way to directly target the vector features themselves
when setting the styles or else tell the editing toolbar layer not to
inherit the styles from the default style?

Here's an example of what I'm getting

http://yfrog.com/74openlayers4g

Thanks everyone,

Chrelad

On Fri, Aug 21, 2009 at 11:53 AM, Christopher Dale<chrelad at gmail.com> wrote:
> Heya Everyone,
>
> I found an example on OpenLayer's site that shows another way of
> accessing and modifying properties of layers.
>
> http://openlayers.org/dev/examples/modify-feature.html
>
> This is the line that worked for me:
>
> OpenLayers.Feature.Vector.style['default']['strokeWidth'] = '2';
>
> Thanks everyone and thanks to team OpenLayers for making something awesome,
>
> Chrelad
>
> On Fri, Aug 21, 2009 at 8:58 AM, Christopher Dale<chrelad at gmail.com> wrote:
>> Hi everyone,
>>
>> This is my first post to the list, so let me know if I'm missing
>> anything or could improve on my posts.
>>
>> I have an OpenLayers map with two layers. The first layer contains
>> virtual earth base tiles (street view) and the second is a vector
>> layer I use in conjunction with the editing toolbar. The map's
>> projection is spherical mercator and everything seems to be working
>> great. However, when I tried to change the weight and color of the
>> polylines created by the editing toolbar, everytime I would click to
>> add a point to the polyline, it would be way off (to the right). The
>> code I used to add the style is below:
>>
>> var layer_style = OpenLayers.Util.extend({},
>> OpenLayers.Feature.Vector.style['default']);
>> layer_style.strokeColor = 'black';
>> vlayer = new OpenLayers.Layer.Vector('Editable', {style: layer_style});
>>
>> It may help to know that vlayer (vector layer) from the aforementioned
>> code is created with sphericalMercator set to true.
>>
>> I used this website as a reference for styling layers:
>> http://openlayers.org/dev/examples/vector-features.html
>>
>> Is this the correct way to go about styling vector features? Is there
>> a different way you have to handle features created using the editing
>> toolbar? Any input would be appreciated :)
>>
>> Thanks everyone and great list,
>>
>> Chrelad
>>
>



More information about the Users mailing list