[OpenLayers-Users] Multiple linestrings originating from the
same point disappear when zooming
Pierre GIRAUD
bluecarto at gmail.com
Sat Jan 19 06:13:39 EST 2008
For your information, your code is correct and I think I've found what
part of the OpenLayers' code is involved in this weird behavior.
I'll try to find out a fix or at least a workaround for this issue. If
your interested in fixing this too, you can have a look at the SVG
renderer (lib/OpenLayers/Renderer/SVG.js) and in particular at
getShortString(), inValidRange() and MAX_PIXEL.
I plan to fill a bug report, but don't hesitate to do so if your quicker.
Hum, I was unable to reproduce the issue under IE with your example.
Regards,
Pierre
On Jan 18, 2008 5:23 PM, cmose <cjmose at gmail.com> wrote:
>
> I have several lineStrings on a vector layer that originate from the same
> lat/lon coordinate. As you zoom in on the map, the lineStrings randomly
> disappear, e.g,. if you start out with 6 lines originating from the same
> point, as you zoom in on the map lines will randomly disappear until there
> are <6 lines left.
>
> I've verified this behavior using a modified version of vector-features.html
> from the examples directory. I don't have anywhere to host my example but
> here is my modified script declaration from vector-features.html:
>
> <script src="../lib/OpenLayers.js" type="text/javascript"></script>
> <script type="text/javascript">
> var map;
>
> function init(){
> map = new OpenLayers.Map('map');
> var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
> "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'}
> );
> map.addLayer(layer);
>
> /*
> * Layer style
> */
> // we want opaque external graphics and non-opaque internal
> graphics
> var layer_style = OpenLayers.Util.extend({},
> OpenLayers.Feature.Vector.style['default']);
> layer_style.fillOpacity = 0.2;
> layer_style.graphicOpacity = 1;
>
> /*
> * Blue style
> */
> var style_blue = OpenLayers.Util.extend({}, layer_style);
> style_blue.strokeColor = "blue";
> style_blue.fillColor = "blue";
>
> /*
> * Green style
> */
> var style_green = {
> strokeColor: "#00FF00",
> strokeWidth: 2,
> pointRadius: 4,
> pointerEvents: "visiblePainted"
> };
>
> /*
> * Mark style
> */
> var style_mark = OpenLayers.Util.extend({},
> OpenLayers.Feature.Vector.style['default']);
> // each of the three lines below means the same, if only one of
> // them is active: the image will have a size of 24px, and the
> // aspect ratio will be kept
> // style_mark.pointRadius = 12;
> // style_mark.graphicHeight = 24;
> // style_mark.graphicWidth = 24;
>
> // if graphicWidth and graphicHeight are both set, the aspect
> ratio
> // of the image will be ignored
> style_mark.graphicWidth = 24;
> style_mark.graphicHeight = 20;
> style_mark.graphicXOffset = -(style_mark.graphicWidth/2); //
> this is the default value
> style_mark.graphicYOffset = -style_mark.graphicHeight;
> style_mark.externalGraphic = "../img/marker.png";
>
> var vectorLayer = new OpenLayers.Layer.Vector("Simple Geometry",
> {style: layer_style});
> var point = OpenLayers.Geometry.Point;
> var ls = OpenLayers.Geometry.LineString;
> var vector = OpenLayers.Feature.Vector;
> var lines = [];
> var features = [];
>
> lines.push(new ls([new point(1,50), new point(75,60)]));
> lines.push(new ls([new point(1,50), new point(-60,-30)]));
> lines.push(new ls([new point(1,50), new point(40,89)]));
> lines.push(new ls([new point(1,50), new point(-150,-55)]));
> lines.push(new ls([new point(1,50), new point(-30,-25)]));
> lines.push(new ls([new point(1,50), new point(-5,-10)]));
>
> for(var i=0;i<lines.length;i++){
> features.push(new vector(lines[i], null, style_green));
> }
>
> map.addLayer(vectorLayer);
> map.setCenter(new OpenLayers.LonLat(1,50), 5);
> vectorLayer.addFeatures(features);
> }
> </script>
>
> The map is initialized with a zoom level of 5. Once you get to 8 one of the
> 6 lines disappears, leaving you with 5. Zoom level 9 removes all but one
> line. Zoom level 10 removes all lines.
>
> I haven't traced the issue beyond drawFeature() in Vector.js. I've tested
> the example in Firefox thus far but in my app I'm getting the same behavior
> in ff and ie.
>
> Any ideas?
> --
> View this message in context: http://www.nabble.com/Multiple-linestrings-originating-from-the-same-point-disappear-when-zooming-tp14952551p14952551.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
>
More information about the Users
mailing list