[OpenLayers-Users] Panning map and bbox/tile position bug?

Ian iansgis at gmail.com
Mon Nov 3 14:28:59 EST 2008


The bounding box and extent of the viewport seems to be corrupted when
panning the map. The actual display of the data is fine, however the
underlying bbox and x/y values for tiles corrupt printed images when using
the Wiki Printing code. While panning the map and then printing will give an
incorrect image result, switching the base layer after panning fixes the
bbox and x/y values and any base layer will print correctly thereafter.
Additional panning does require additional base layer switches to fix the
extent again.

Test map:

 function loadMap(){
          map = new OpenLayers.Map( 'map' );
          var lon = -119.2;
          var lat = 37;
          var zoom = 4;
          var lyrSw = new OpenLayers.Control.LayerSwitcher();
          map.addControl(lyrSw);
          var ol_wms = new OpenLayers.Layer.WMS("basic","
http://labs.metacarta.com/wms/vmap0",{layers: 'basic'});
          var satellite = new OpenLayers.Layer.WMS("sat", "
http://hypercube.telascience.org/cgi-bin/landsat7?", {layers:'landsat7'},
{format: 'image/jpeg', wrapDateLine: false});

          map.addLayers([ol_wms,satellite]);
          map.setCenter(new OpenLayers.LonLat(lon,lat),zoom);
   }


To reproduce this behavior:
1. Print the initial map (works correctly)
2. Pan the map and print (incorrect map extent with vertical black band on
left side of image)
3. Switch the base layer and print (works correctly)
4. Switch back to initial base layer and print (now works correctly)

Following are debugging excerpts of each tile's url and x/y positions from
printMap.php:

Pan the map and print:

http://url?LAYERS=basic&BBOX=-123.75,50.625,-118.125,56.25&WIDTH=256&HEIGHT=256,
x: 43, y: -626
http://url?LAYERS=basic&BBOX=-118.125,50.625,-112.5,56.25&WIDTH=256&HEIGHT=256,
x: 299, y: -626
http://url?LAYERS=basic&BBOX=-112.5,50.625,-106.875,56.25&WIDTH=256&HEIGHT=256,
x: 555, y: -626
http://url?LAYERS=basic&BBOX=-106.875,50.625,-101.25,56.25&WIDTH=256&HEIGHT=256,
x: 811, y: -626
http://url?LAYERS=basic&BBOX=-101.25,50.625,-95.625,56.25&WIDTH=256&HEIGHT=256,
x: 1067, y: -626
http://url?LAYERS=basic&BBOX=-95.625,50.625,-90,56.25&WIDTH=256&HEIGHT=256,
x: 1323, y: -626
http://url?LAYERS=basic&BBOX=-90,50.625,-84.375,56.25&WIDTH=256&HEIGHT=256,
x: 1579, y: -626
http://url?LAYERS=basic&BBOX=-123.75,45,-118.125,50.625&WIDTH=256&HEIGHT=256,
x: 43, y: -370
http://url?LAYERS=basic&BBOX=-118.125,45,-112.5,50.625&WIDTH=256&HEIGHT=256,
x: 299, y: -370
http://url?LAYERS=basic&BBOX=-112.5,45,-106.875,50.625&WIDTH=256&HEIGHT=256,
x: 555, y: -370
http://url?LAYERS=basic&BBOX=-106.875,45,-101.25,50.625&WIDTH=256&HEIGHT=256,
x: 811, y: -370
http://url?LAYERS=basic&BBOX=-101.25,45,-95.625,50.625&WIDTH=256&HEIGHT=256,
x: 1067, y: -370
http://url?LAYERS=basic&BBOX=-95.625,45,-90,50.625&WIDTH=256&HEIGHT=256, x:
1323, y: -370
http://url?LAYERS=basic&BBOX=-90,45,-84.375,50.625&WIDTH=256&HEIGHT=256, x:
1579, y: -370

Switch base layer to sat and print:

http://url?LAYERS=sat&BBOX=-129.375,56.25,-123.75,61.875&WIDTH=256&HEIGHT=256,
x: -652, y: -762
http://url?LAYERS=sat&BBOX=-123.75,56.25,-118.125,61.875&WIDTH=256&HEIGHT=256,
x: -396, y: -762
http://url?LAYERS=sat&BBOX=-118.125,56.25,-112.5,61.875&WIDTH=256&HEIGHT=256,
x: -140, y: -762
http://url?LAYERS=sat&BBOX=-112.5,56.25,-106.875,61.875&WIDTH=256&HEIGHT=256,
x: 116, y: -762
http://url?LAYERS=sat&BBOX=-106.875,56.25,-101.25,61.875&WIDTH=256&HEIGHT=256,
x: 372, y: -762
http://url?LAYERS=sat&BBOX=-101.25,56.25,-95.625,61.875&WIDTH=256&HEIGHT=256,
x: 628, y: -762
http://url?LAYERS=sat&BBOX=-95.625,56.25,-90,61.875&WIDTH=256&HEIGHT=256, x:
884, y: -762
http://url?LAYERS=sat&BOX=-129.375,50.625,-123.75,56.25&WIDTH=256&HEIGHT=256,
x: -652, y: -506
http://url?LAYERS=sat&BBOX=-123.75,50.625,-118.125,56.25&WIDTH=256&HEIGHT=256,
x: -396, y: -506
http://url?LAYERS=sat&BBOX=-118.125,50.625,-112.5,56.25&WIDTH=256&HEIGHT=256,
x: -140, y: -506
http://url?LAYERS=sat&BBOX=-112.5,50.625,-106.875,56.25&WIDTH=256&HEIGHT=256,
x: 116, y: -506
http://url?LAYERS=sat&BBOX=-106.875,50.625,-101.25,56.25&WIDTH=256&HEIGHT=256,
x: 372, y: -506
http://url?LAYERS=sat&BBOX=-101.25,50.625,-95.625,56.25&WIDTH=256&HEIGHT=256,
x: 628, y: -506
http://url?LAYERS=sat&BBOX=-95.625,50.625,-90,56.25&WIDTH=256&HEIGHT=256, x:
884, y: -506

Switch base layer back to basic and print:

http://url?LAYERS=basic&BBOX=-129.375,56.25,-123.75,61.875&WIDTH=256&HEIGHT=256,
x: -652, y: -762
http://url?LAYERS=basic&BBOX=-123.75,56.25,-118.125,61.875&WIDTH=256&HEIGHT=256,
x: -396, y: -762
http://url?LAYERS=basic&BBOX=-118.125,56.25,-112.5,61.875&WIDTH=256&HEIGHT=256,
x: -140, y: -762
http://url?LAYERS=basic&BBOX=-112.5,56.25,-106.875,61.875&WIDTH=256&HEIGHT=256,
x: 116, y: -762
http://url?LAYERS=basic&BBOX=-106.875,56.25,-101.25,61.875&WIDTH=256&HEIGHT=256,
x: 372, y: -762
http://url?LAYERS=basic&BBOX=-101.25,56.25,-95.625,61.875&WIDTH=256&HEIGHT=256,
x: 628, y: -762
http://url?LAYERS=basic&BBOX=-95.625,56.25,-90,61.875&WIDTH=256&HEIGHT=256,
x: 884, y: -762
http://url?LAYERS=basic&BBOX=-129.375,50.625,-123.75,56.25&WIDTH=256&HEIGHT=256,
x: -652, y: -506
http://url?LAYERS=basic&BBOX=-123.75,50.625,-118.125,56.25&WIDTH=256&HEIGHT=256,
x: -396, y: -506
http://url?LAYERS=basic&BBOX=-118.125,50.625,-112.5,56.25&WIDTH=256&HEIGHT=256,
x: -140, y: -506
http://url?LAYERS=basic&BBOX=-112.5,50.625,-106.875,56.25&WIDTH=256&HEIGHT=256,
x: 116, y: -506
http://url?LAYERS=basic&BBOX=-106.875,50.625,-101.25,56.25&WIDTH=256&HEIGHT=256,
x: 372, y: -506
http://url?LAYERS=basic&BBOX=-101.25,50.625,-95.625,56.25&WIDTH=256&HEIGHT=256,
x: 628, y: -506
http://url?LAYERS=basic&BBOX=-95.625,50.625,-90,56.25&WIDTH=256&HEIGHT=256,
x: 884, y: -506

I also noted that layer.getTilesBounds() gives different bounds for a layer
before/after "fixing" it via a base layer switch. If someone will confirm
that this is a bug and not the result of a glaring omission on my part, I
will file it. A quick look through known bugs didn't find anything along
these lines.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20081103/a30c1080/attachment.html


More information about the Users mailing list