[OpenLayers-Dev] moving WMS tiles over Google

Steven M. Ottens steven at minst.net
Wed Jul 18 04:46:10 EDT 2007


Hi all,

I noticed some weird behavior of WMS tiles in combination with google 
maps. The bounding box of the WMS tiles is not constant when resizing 
the map. The tiles are moving in respect to the google tiles. The 
behavior is the most visible in the current trunk, since the tiles move 
both horizontal and vertical.
But the 2.4 release suffers from the same problem; the tiles move 
vertically.

I've only investigated trunk thoroughly and discovered that it's caused 
by Google recentering the map after a resize:
After a resize Map.setCenter is called this retrieves the current 
Extent, which is the one after the resize, but before the 
Google-triggered resize. This extent is stored as bounds and this bounds 
is used later on by Grid.initGriddedTiles to calculate the number of 
rows and columns and their position over google maps.
At this point Google has changed the extent and the calculated WMS-tile 
position is off by half the resize distance. This new tile location is 
used by Tile.getBoundsFromBaseLayer to calculate the Tile bounds. These 
tile bounds are calculated against the new Extent and as such fit over 
the Google layer.

Since everything fits it's hard to notice the problem, the easiest way 
is to outline both the DIVs (WMS layer) and the Images (google layer) 
and resize your window.

I found that using the current Extent in Gid.initGriddedTiles solves 
both the horizontal and vertical movement. I added 
bounds=this.getExtent(); as the first line of the function, overruling 
the bounds which is given from Map.setCenter. I also noticed that in 
previous version Grid.initTile (the predecessor of initGriddedTiles) 
used bounds=this.getExtent so I'm curious why this has changed, can 
anyone enlighten me? (also I'm wondering why 2.4 with initTile still 
suffers from vertical movement)

Regards,
Steven






More information about the Dev mailing list