[OpenLayers-Users] Map won't zoom to full extent
Semantica
jvanulde at nrcan.gc.ca
Thu Aug 21 18:44:46 EDT 2008
Hi all,
I submittted a related post earlier. I am loading a web map context
document into a map. I am setting the map extent to context.bounds but no
dice. I have tried setting the map extent to format.context.bounds but got
a null reference error. Here is the relavant code:
function initMap()
{
// parse wmc into context object
var wmc = document.getElementById('hidWMC').value;
if(wmc)
{
context = format.read(wmc, {map: map});
for (var i=0; i<context.layers.length;i++)
{
var layer = context.layers[i];
layer.params.TRANSPARENT = 'TRUE';
}
// construct a map
var mapOptions = {
maxExtent: context.bounds,
projection: context.srs
};
map = new OpenLayers.Map("map", mapOptions);
// create a fake base layer
var baseLayerOptions = {
isBaseLayer: true,
displayInLayerSwitcher: false
};
var fake = new OpenLayers.Layer('fake', baseLayerOptions);
map.addLayer(fake);
// add the context layers to the map
map.addLayers(context.layers);
// zoom to the maximum extent
map.zoomToMaxExtent();
}
}
Here is a screenshot: http://n2.nabble.com/file/n741546/screenshot.png
screenshot.png
Any ideas on how I can get the map to zoom the the extent of the context
document?
Thank you in advance!
--
View this message in context: http://n2.nabble.com/Map-won%27t-zoom-to-full-extent-tp741546p741546.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list