[OpenLayers-Users] maxExtent error

Christopher Schmidt crschmidt at metacarta.com
Tue Jan 12 15:15:19 EST 2010


On Tue, Jan 12, 2010 at 11:41:48AM -0800, raul1113 wrote:
> 
> I'm dealing with issue for a long time with any luck to solve it.
> 
> I have a WMS server of my own with different layers on it, but I have to
> include the metacarta layer from internet otherwise I get this error:
> 
> maxExtent is null
> http://192.168.1.5:9090/SMMS/wms/client/OpenLayers.js
> Line 840

This means you don't have a base layer.

> And then I have to click in the max zoom button of OpenLayers tools to get
> the complete world view and then find the part I'm interested. Ive tried
> different solutions posted by users of the mailing list without luck. This
> is my code, is a little long but could be useful to anyone who can help me.
> Thanks in advance.
> 
> <div style="width:50em; height:35em;" id="map"></div>
>                         <script defer="defer" type="text/javascript">
> 
>                         layers_array = new Array();
>                         var lon = -87.29301;
>                         var lat = 13.33182;
>                         var zoom = 10;
>                    
>             var options = {
>                                                         numZoomLevels: 16,
>                                                     maxResolution: "auto",
>                             units: 'meters',
>                             maxExtent: new OpenLayers.Bounds(-180, -90, 180,
> 90)
>                           };
> 
>            var map = new OpenLayers.Map( 'map' , options);
>            
>            OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;
>            OpenLayers.Util.onImageLoadErrorColor = "transparent";
>                  
>                         var request = OpenLayers.Request.GET(
>                         {url:
> "dir/wms.php?VERSION=1.1.1&REQUEST=GetCapabilities&SERVICE=WMS",
>                         success: function(response){
>                                                         var XMLformat = new
> OpenLayers.Format.XML();
>                                                         var xml =
> XMLformat.read(response.responseText);
>                                                         var CAPformat = new
> OpenLayers.Format.WMSCapabilities();
>                                                         var cap =
> CAPformat.read(xml);
>                                                        
>                                                         for (var i=0;
> i<cap.capability.layers.length; i++) {
>                                                                 layer =
> cap.capability.layers[i];
>                                                                                        
>                         layers_array[i] = new OpenLayers.Layer.WMS(
> layer.name,
>                                                                                                
> "dir/wms.php",
>                                                                                                
> {'layers': layer.name, transparent: "true", format: "image/png", 'viewer':
                                  ^^ This is why you don't have a base layer.

> 'OpenLayers'}
>                                                                                                
> );
>                                                                                        
> }
> 
>                                                                                        
> }
>                                                                
> map.addLayer(layers_array[i]);
>                                                         }
>                                                        
>                                                 },
>                                 failure: function(response){
>                                                        
> alert(response.status);
>                                                        
> alert("GetCapabilities failed");
>                                                                 }
>                         });
>                        
>              layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
>                  "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'});
>             map.addLayer(layer);/*WITHOUT THIS I GET THE ERROR MENTIONED
> BEFORE*/
>                                                
>                 map.addControl(new OpenLayers.Control.LayerSwitcher());
>                 map.addControl( new OpenLayers.Control.MousePosition());
>                 map.addControl( new OpenLayers.Control.MouseToolbar());
>                 map.addControl( new OpenLayers.Control.OverviewMap());
>        
>         map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
> </script> 
> -- 
> View this message in context: http://n2.nabble.com/maxExtent-error-tp4293879p4293879.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users

-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list