[OpenLayers-Users] Lines offset by x pixels disappearing at higher zoom levels

cheunglucia cheunglucia at gmail.com
Sat Sep 29 23:09:43 PDT 2012


Hello all,

I need to draw straight lines from A to B and from B to A.  Since I need to
give each line a different weight, I cannot just draw one line.  For now,
I'm offsetting the lines perpendicularly by a certain number of pixels so
they don't overlap.

To do this, I'm adding the offset to the vertices on each redraw using the
context functions for the styles.  I'm not sure this is the best place/way
to do it, but I couldn't find any callback for redraw().

It works fine except at higher zoom levels, in which the lines unexpectedly
disappear.

Here is the code: http://jsfiddle.net/G5UDF/6/
(I've tried with versions 2.10, 2.11 and 2.12, same result; tested in Chrome
and Firefox)

I have read posts about long linestrings disappearing at higher zoom levels
because the browser runs out of coordinate space. But the line I'm drawing
is not very long, and also, it works fine if I just don't add the offset.

In the code you will see that either if I call layer.getDataExtent() before
setting the map extent/center or use it to define the map extent, the lines
won't disappear.  Also, they won't disappear if I just set a fixed value for
the resolution (e.g. adding res = 4.77 after res = map.getResolution() to
overwrite it), which is very strange.

So my questions would be:
- Is there a better way to define an offset in pixels for the lines?
- Am I doing something wrong that makes the lines disappear?



--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Lines-offset-by-x-pixels-disappearing-at-higher-zoom-levels-tp5005365.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list