Thank you for the assistance, the problem was indeed trying to set the center of my map before hand and when I switched this configuration to the actual map panel it worked perfectly, thanks again!
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Eric Lemoine Sent: September 21, 2010 1:51 AM To: Andrew Stewart Cc: [email protected] Subject: Re: [Users] MapPanel overwriting my map getextent? On Mon, Sep 20, 2010 at 11:50 PM, Andrew Stewart <[email protected]> wrote: > I am trying to display my map inside of a mappanel and ext window. Below > is my code and I am using the same exact settings as a map on a different > page that shows all my layers without issues. However when I add this to an > ext.window and panel it loads but no layers show up as if the zoom > level/maxextent is wrong. any ideas? > > > > <script type="text/javascript"> > > // begin map defintion > var map = new OpenLayers.Map('map',{ This is probably not related to your problem, but you shouldn't pass a div to the Map constructor when working with a MapPanel, so just pass the options object as the first argument to the constructor. > maxExtent: new OpenLayers.Bounds(-20037508.34, > -20037508.34, 20037508.34, 20037508.34), > maxResolution: 156543.0399, > units: 'km', > projection: new OpenLayers.Projection("EPSG:900913"), > displayProjection: new > OpenLayers.Projection("EPSG:4326") > } > ); //end of map definition > > //Base Layer - contains all base layers (everything except transit > routes/bus stops) > var layer_Base = new OpenLayers.Layer.WMS("Base Layer", > "http://ITS701X5J1/RedWMS/Request.aspx", > { > layers: > ['BAS_NEIGHBOURHOOD_SHAPE,BAS_NEIGHBOURHOOD_SHAPE1,BAS_RURAL_BLOCK_LINE,BAS_RURAL_LOT_LINE,LRSV_STREET_SEGMENT,LRSV_SECONDARY_SEGMENT,WWW_PARCELS,BAS_HYDRO,BAS_CITY_BOUNDARY_LINE, > Arterial,Highway,Rural_Highway,BAS_BRIDGE'], > format: 'image/png', > VERSION: "1.1.1", > transparent: true > }, > { isBaseLayer: true, > singleTile: true > } > ); > > map.addLayer(layer_Base); > > //Define Map Longitude/Latitude and Start zoom levels > var startupLat = 52.27210; > var startupLon = -113.80288; > var startupLevel = 12; > var lonLat = new OpenLayers.LonLat(startupLon, > startupLat).transform(new OpenLayers.Projection("EPSG:4326"), > map.getProjectionObject()); > > map.setCenter(lonLat,startupLevel); You shouldn't call setCenter yourself when working with a MapPanel. Instead set the "center" and "zoom" options in the MapPanel config. See below. > > > var mapPanel; > Ext.onReady(function() { > new Ext.Window({ > title: "GeoExt MapPanel Window", > height: 400, > width: 600, > layout: "fit", > items: [{ > xtype: "gx_mappanel", > id: "mappanel", > map: map center: lonLat, zoom: startupLevel > }] > }).show(); > > mapPanel = Ext.getCmp("mappanel"); > });</script> Hope it helps. -- Eric Lemoine Camptocamp France SAS Savoie Technolac, BP 352 73377 Le Bourget du Lac, Cedex Tel : 00 33 4 79 44 44 96 Mail : [email protected] http://www.camptocamp.com _______________________________________________ Users mailing list [email protected] http://www.geoext.org/cgi-bin/mailman/listinfo/users [This message has been scanned for security content threats and viruses.] [The City of Red Deer I.T. Services asks that you please consider the environment before printing this e-mail.] _______________________________________________ Users mailing list [email protected] http://www.geoext.org/cgi-bin/mailman/listinfo/users
