[OpenLayers-Users] zooming out when changing base layer
Bart van den Eijnden (OSGIS)
bartvde at osgis.nl
Wed Dec 27 11:37:43 EST 2006
I have debugged this problem a little bit and "patched" my local version.
My base layers are all WMS Untiled.
What I understand from it, WMS Untiled does not inherit from
FixedZoomLevels, so does not have any zoom levels.
The behaviour I see (i.e. when changing base layer sometimes the map zooms
out) is caused by the following call in changeBaseLayer (Map.js):
this.zoomToExtent(oldBaseLayer.getExtent());
The getExtent call does give back to correct extent btw of the current map.
I made the following adjustment by checking on class name, but there is
probably a nicer solution to this problem:
} else {
if (!newBaseLayer.CLASS_NAME ==
'OpenLayers.Layers.WMS.Untiled')
this.zoomToExtent(oldBaseLayer.getExtent());
}
Does anybody have a better idea on how to tackle this? Can we for instance
check if the BaseLayer inherits from FixedZoomLevels?
Best regards,
Bart
--
Bart van den Eijnden
OSGIS, Open Source GIS
http://www.osgis.nl
--------- Oorspronkelijk bericht --------
Van: Bart van den Eijnden OSGIS <bartvde at osgis.nl>
Naar: Erik Uzureau <euzuro at gmail.com>, Bart van den Eijnden OSGIS
<bartvde at osgis.nl>
Cc: users at openlayers.org
Onderwerp: Re: [OpenLayers-Users] zooming out when changing base layer
Datum: 11/12/06 11:40
>
> Hi Erik,
>
> but with WMS Untiled, I do not specify an extent nor a resolution for a
> layer.
>
> How does this relate then to WMS Untiled? Is there a way around it?
>
> This is my code:
>
> function mapinit(){
> map = new OpenLayers.Map( $('map'), { controls: [],
> 'projection': 'EPSG:28992', 'units':'meters', 'maxExtent': new
> OpenLayers.Bounds(-157973.103596, 300670.145842, 472056.321374,
> 678687.800824) , 'maxResolution':'auto'}); var layer = new
> OpenLayers.Layer.WMS.Untiled( "Topografische kaart Nederland",
>
>
"http://intranet.rijkswaterstaat.nl/services/geoservices/basispakket/topografie?",
> {layers: 'AAA126,AAA127,AAA134', 'format':'image/jpeg',
> 'transparent':'true'}, {'ratio':1, isBaseLayer: true} );
>
> map.addLayers([layer]); var layer = new
> OpenLayers.Layer.WMS.Untiled( "Luchtfoto's Nederland",
>
>
"http://intranet.rijkswaterstaat.nl/services/geoservices/basispakket/luchtfoto?",
> {layers: 'AAA216', 'format':'image/jpeg', 'transparent':'true'},
{'ratio':1,
> isBaseLayer: true} );
>
> map.addLayers([layer]); var layer = new
> OpenLayers.Layer.WMS.Untiled( "Nationaal Wegen Bestand Wegen
wegvakken",
>
>
"http://intranet.rijkswaterstaat.nl/services/geoservices/basispakket/nationaalwegenbestand?",
> {layers: 'AAA70', 'format':'image/gif', 'transparent':'true'}, {'ratio':1,
> isBaseLayer: false} );
>
> map.addLayers([layer]); var layer = new
> OpenLayers.Layer.WMS.Untiled( "Top250namen",
>
>
"http://intranet.rijkswaterstaat.nl/services/geoservices/basispakket/topografie?",
> {layers: 'AAA133', 'format':'image/gif', 'transparent':'true'},
{'ratio':1,
> isBaseLayer: false} );
>
> map.addLayers([layer]); if (!map.getCenter())
> map.zoomToMaxExtent();
> map.addControl(new OpenLayers.Control.LayerSwitcher());
> map.addControl(new OpenLayers.Control.PanZoomBar());
> map.addControl(new OpenLayers.Control.MouseDefaults());
> }
>
> Best regards,
> Bart
>
> --
> Bart van den Eijnden
> OSGIS, Open Source GIS
> http://www.osgis.nl
>
>
> --------- Oorspronkelijk bericht --------
> Van: Erik Uzureau <euzuro at gmail.com>
> Naar: Bart van den Eijnden OSGIS <bartvde at osgis.nl>
> Cc: users at openlayers.org
> Onderwerp: Re: [OpenLayers-Users] zooming out when changing base layer
> Datum: 11/12/06 09:16
>
> > When you switch between base layers, OpenLayers tries to find the
> > nearest approximate
> > zoom for the new base layer.
> >
> > So what is happening is that when you switch from baselayer A to
baselayer
> B
> >
> > 1) records current extent of map in baselayer A
> > 2) switches to base layer B
> > 3) calls zoomToExtent() on stored extent from base layer A
> >
> > if the resolutions/scales array for your two base layers are not the
same,
> > this would explain the behaviour.
> >
> > Note that with the commercial layers (google, yahoo, etc) we have
> specifically
> > hard coded the resolutions array so that it will be more consistent
with
> wms
> > layers (due to projection differences).
> >
> > On 12/11/06, Bart van den Eijnden (OSGIS)
&lt;bartvde at osgis.nl&gt; wrote:
> > &gt; Hi list,
> > &gt;
> > &gt; I have 2 base layers and several overlays, all are WMS
Untiled.
> > &gt;
> > &gt; When I change the base layer, the application zooms out.
> > &gt;
> > &gt; Is this a bug?
> > &gt;
> > &gt; Best regards,
> > &gt; Bart
> > &gt;
> > &gt; --
> > &gt; Bart van den Eijnden
> > &gt; OSGIS, Open Source GIS
> > &gt; http://www.osgis.nl
> > &gt;
> > &gt;
> > &gt;
> > &gt;
> > &gt;
> > &gt; _______________________________________________
> > &gt; Users mailing list
> > &gt; Users at openlayers.org
> > &gt; http://openlayers.org/mailman/listinfo/users
> > &gt;
> >
> >
>
>
More information about the Users
mailing list