[OpenLayers-Users] Zoomtoextent doesnt synchronize for different
maps
vsambhe
vsambhe at imgs.ie
Fri Jun 18 07:30:02 EDT 2010
Hi,
My work flow is
1. Click on one of the icon from customized Legends (Each lagend represents
maps with no of layers)
2. Get and store existing Map's extent as oExtent1 =
oMapControl.getExtent();
3. Destroy existing Map.
4. Call javascript. Javascript creates map options with bounds, then map
control and add layers and then zoom to given bound.
5. Zoom the Map to the extent recieved from step 2 i.e. from the previous
map.
My problem is
If my old map was on an area, I get it's extent and zoom the new map to that
extent but then I observe that new map doesn't show same extent. it is more
or less zoomed area. I want the extent to remain constant so that use gets
the feel that he is just switching the map type for the same area.
generic code is
function loadNewMap()
{
oExtent1 = oMapControl.getExtent();
oMapControl.destroy();
CreateNewMap();
oMapControl.zoomToExtent(oExtent1);
}
function CreateNewMap()
try {
//predefined bound
var mybounds = new OpenLayers.Bounds(-1693861.59, 6469059.01,
-107949.94, 7643808.37);
oMapOptions = {
controls: [
new OpenLayers.Control.Navigation()
, new OpenLayers.Control.LayerSwitcher()
, new OpenLayers.Control.PanZoomBar()
]
, maxResolution: 'auto'
, units: 'm'
, maxExtent: mybounds
, projection: new OpenLayers.Projection("EPSG:4326")
, displayProjection: new OpenLayers.Projection("EPSG:4326")
};
//-----Create Map Control Object ------------
oMapControl = new OpenLayers.Map('MapPanel', oMapOptions);
//----------WMS----------
var myscales = [14000000, 7000000, 3000000, 2000000, 867000,
433000, 217000, 108000, 54000, 27000, 14000, 6771, 3386, 1963, 846];
var oPreviewLayer = new OpenLayers.Layer.WMS('Counties (WMS)',
'http://MyServer/Request.aspx',
{
layers: ['Cities'],
format: 'image/png',
VERSION: "1.1.1",
transparent: true
},
{ isBaseLayer: false
, singleTile: true
}
);
if (oPreviewLayer != null) {
oMapControl.addLayer(oPreviewLayer);
}
//----------Bing Aerial----------
var myscales = [14000000, 7000000, 3000000, 2000000, 867000,
433000, 217000, 108000, 54000, 27000, 14000, 6771, 3386, 1963, 846];
var oPreviewLayer = new OpenLayers.Layer.VirtualEarth("Bing
Aerial",
{ type: VEMapStyle.Aerial, sphericalMercator: true,
animationEnabled: false,
numZoomLevels: 20
});
oPreviewLayer.setIsBaseLayer(true);
if (oPreviewLayer != null) {
oMapControl.addLayer(oPreviewLayer);
oMapControl.setBaseLayer(oPreviewLayer);
}
oMapControl.zoomToExtent(mybounds);
}
catch (e)
{ alert(e.message); }
finally { }
}
Can anyone tell me how to achieve synchronozed map switching?
Thanks
Vijay
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Zoomtoextent-doesnt-synchronize-for-different-maps-tp5194923p5194923.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list