[OpenLayers-Users] toggling between WMS base layer and Google base layer causes viewport to drift

Bill Woodall bwoodall at bwoodall.org
Thu May 24 03:16:26 EDT 2007


Hi Mike,

Hi Mike,

I've not seen it drift eastward only south or north.

There are many sites that give good information about the workings of
Gmaps, but the one that help me the most when I was making OL do Gmaps
with WMS overlays ( and TC) was
http://www.ponies.me.uk/maps/dbgmap.html

The artifact that you might be seeing is that the change in Lat is not
constant in Gmaps.  Thus making the jump from a standard WMS layer to
Gmap layer will get askew in the North-South.

Below is a table shows the numbers of a Gmap for zoom level 9, decimal
degree 91 , (1-5,254-258,507-511)
Take a look at the Lat deltas

Lon delta   Lat delta     LL Lon     LL Lat           UR Lon   UR Lat
0.703125 0.0617792507352 -116.015625 84.9283209295   -115.3125 84.9901001802
0.703125 0.0625390621844 -116.015625 84.8657818673   -115.3125 84.9283209295
0.703125 0.0633081429807 -116.015625 84.8024737243   -115.3125 84.8657818673
0.703125 0.0640866033811 -116.015625 84.738387121    -115.3125 84.8024737243
0.703125 0.0648745548481 -116.015625 84.6735125661   -115.3125 84.738387121
0.703125 0.703001482999  -116.015625  0.703107352436 -115.3125  1.40610883544
0.703125 0.703107352436  -116.015625  0.0            -115.3125  0.703107352436
0.703125 0.703107352436  -116.015625 -0.703107352436 -115.3125  0.0
0.703125 0.703001482999  -116.015625 -1.40610883544  -115.3125 -0.703107352436
0.703125 0.702789823808  -116.015625 -2.10889865924  -115.3125 -1.40610883544
0.703125 0.0640866033811 -116.015625 -84.8024737243  -115.3125 -84.738387121
0.703125 0.0633081429807 -116.015625 -84.8657818673  -115.3125 -84.8024737243
0.703125 0.0625390621844 -116.015625 -84.9283209295  -115.3125 -84.8657818673
0.703125 0.0617792507352 -116.015625 -84.9901001802  -115.3125 -84.9283209295
0.703125 0.0610285995718 -116.015625 -85.0511287798  -115.3125 -84.9901001802

Hope that made some sense

..........Bill,

On Wed, 2007-05-23 at 16:36 -0700, Mike Quentel wrote:
> There is a WMS base layer in WGS84 (EPSG: 4326) that is the default base layer (it's visible after the map first launches).
> 
> There is a Google base layer as well.  As you probably know, the Google layer is in some kind of Mercator, with zoom resolutions that cannot be modified.
> 
> Additionally, there are WMS overlays in WGS84.
> 
> When user toggles the radio options back and forth between the WMS and Google, the view port "drifts" eastward.  The WMS overlays look proper on the Google layer (they stretch on to Google correctly), but there is always this shift of the viewport.  It's an annoyance for our users when their viewport extents suddenly shift, and they have to drag the map back to where it was.
> 
> I've been trying to find a solution for this issue.  In OpenLayers.Control.LayerSwitcher, I've tried to add a member to store the older extent information of the default (non-Google) base layer, as well as a function to directly tell Google to set its centre to the older centre, like this:
> 
>     /** @type Bounds */
>     olderCentre: null,
> 
>     
>     updateGoogle: function() {
>       var currentBaseLayer = this.map.baseLayer;
>       if (currentBaseLayer != null) {
>         if (currentBaseLayer.CLASS_NAME != "OpenLayers.Layer.Google") {
>           this.olderCentre = currentBaseLayer.getExtent();
>           alert("this.olderCentre: " + this.olderCentre);
>         } else {
>           var gLatLon = new GLatLng(this.olderCentre.getCenterLonLat().lat, this.olderCentre.getCenterLonLat().lon);
>           this.mapObject.setCenter(gLatLon);
>         } 
>       }    
>     },
> 
> I'm getting the impression that this is not a good way to enforce the map extents in this user scenario.  Not even sure where to attempt to call the function above.  I am getting nowhere with this approach.
> 
> Please, any advice?
> 
> Mike Quentel
> 
> 
> 
> 
>       ___________________________________________________________
> Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
> now.
> http://uk.answers.yahoo.com/ 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users




More information about the Users mailing list