[OpenLayers-Users] Map won't zoom to full extent

Semantica jvanulde at nrcan.gc.ca
Wed Aug 27 19:29:57 EDT 2008


So I fixed the issue by doing a map.zoomIn();

Now the map loads to context extent.


Chris Adams wrote:
> 
> This is because your resolutions do not allow for it.
> 
> If you want your the whole map to fit the visible extents, you will 
> either need to adjust the size of your map so it fits, or adjust your 
> highest resolution. Even adjusting your resolution, you may still need 
> to change the width or height of your map, depending on the aspect 
> ratio. (Unless of course you want to write a custom projection :) )
> 
> Semantica wrote:
>> 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!
>>
>>
>>   
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 
> 



-- 
View this message in context: http://n2.nabble.com/Map-won%27t-zoom-to-full-extent-tp741546p788304.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list