Hi Matt

I suggest you use firefox and the firebug extension to develop with. I loaded 
your js and firebug immediately showed me you had unterminated string literals 
in your extent definition

var extent = new OpenLayers.Bounds(-7.423, 50.102, 
-0.383, 60.988).transform( 
new OpenLayers.Projection("EPSG:4326), 
new OpenLayers.Projection("EPSG:900913) 
); 

I should be 

var extent = new OpenLayers.Bounds(-7.423, 50.102, 
-0.383, 60.988).transform( 
new OpenLayers.Projection("EPSG:4326"), 
new OpenLayers.Projection("EPSG:900913") 
); 

I get a map fixing these. Try this, and if your WMS layer doesn't show, check 
the firebug Net tab and see what the response to your request was and you 
should be able to troubleshoot from there.

hth,
charles

----- Original Message -----
From: "Matt Travis" <[email protected]>
To: "Charles Galpin" <[email protected]>
Cc: [email protected]
Sent: Sunday, December 5, 2010 6:16:38 AM GMT -05:00 US/Canada Eastern
Subject: Re: [OpenLayers-Users] Transform Bounds to EPSG:4326 projection

Thanks for advice Charles. I tried what you suggested but get a blank map 
still. I moved the extent declaration above the options but do they need to be 
inside the function or outside? 
For the record I have tried both methods. As you can probably tell I'm a new to 
javascript. 




Thanks 


Matt 




var map; 


// Avoid pink error tiles 


OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3; 


OpenLayers.Util.onImageLoadErrorColor = "transparent"; 




var extent = new OpenLayers.Bounds(-7.423, 50.102, 
-0.383, 60.988).transform( 
new OpenLayers.Projection("EPSG:4326), 
new OpenLayers.Projection("EPSG:900913) 
); 




function init(){ 


// Map is in mercator this time, so over-ride the default 


// options that assume lat/lon. 
var options = { 


projection: new OpenLayers.Projection("EPSG:900913"), 


displayProjection: new OpenLayers.Projection("EPSG:4326"), 


units: "m", 


numZoomLevels: 20, 


maxResolution: 156543.0339, 


maxExtent: extent 


}; 


// Create the map object 


map = new OpenLayers.Map('map', options); 






// create Google Maps layer 


var gmap = new OpenLayers.Layer.Google( 


"Google Streets", // the default 


{'sphericalMercator': true, numZoomLevels: 20} 


); 






// create Google Satellite layer 


var gsat = new OpenLayers.Layer.Google( 


"Google Satellite", 


{type: G_SATELLITE_MAP, 'sphericalMercator': true, numZoomLevels: 20} 


); 






// create WMS Atrina layer 


var wmslayer = new OpenLayers.Layer.WMS( 


"Atrina", 


" http://localhost:8080/geoserver/wms ", 


{'layers': 'DASSH:Atrina', 'format':'image/png', 'transparent':'true'}, 


{'opacity': 1.0, 'isBaseLayer': false, 'visibility': true} 


); 









map.addLayers([gmap, gsat, wmslayer]); 


map.addControl(new OpenLayers.Control.LayerSwitcher()); 


map.addControl(new OpenLayers.Control.MousePosition()); 
map.zoomToMaxExtent() 


} 






-------------------------------------------------------------------------------------------------------------------------------
 
-------------------------------------------------------------------------------------------------------------------------------
 







On Sat, Dec 4, 2010 at 3:34 PM, Charles Galpin < [email protected] > wrote: 



Matt, try setting the maxExtent of the map. Move the declaration of extent to 
above the options and add 


maxExtent: extent, 


to the options. 


hth, 
charles 






On Dec 4, 2010, at 10:00 AM, Matt Travis wrote: 






Hi all 

I'm trying to start a map using the following function. I want to open using 
some prescribed bounds that are in long, lat (ESPG:4326) but i'm using google 
maps for the baselayer so the projection is EPSG:900913. I thought the 
following code would work ok but it just loads a blank map. 


Regards 


Matt 






function init(){ 
// Map is in mercator this time, so over-ride the default 
// options that assume lat/lon. 
var options = { 
projection: new OpenLayers.Projection("EPSG:900913"), 


displayProjection: new OpenLayers.Projection("EPSG:4326"), 


units: "m", 


numZoomLevels: 20, 


maxResolution: 156543.0339, 

}; 

var extent = new OpenLayers.Bounds(-7.423, 50.102, 
-0.383, 60.988).transform( 
new OpenLayers.Projection("EPSG:4326), 
new OpenLayers.Projection("EPSG:900913) 

); 

// Create the map object 
map = new OpenLayers.Map('map', options); 


// create Google Maps layer 
var gmap = new OpenLayers.Layer.Google( 
"Google Streets", // the default 
{'sphericalMercator': true, numZoomLevels: 20} 
); 


// create Google Satellite layer 
var gsat = new OpenLayers.Layer.Google( 
"Google Satellite", 
{type: G_SATELLITE_MAP, 'sphericalMercator': true, numZoomLevels: 20} 
); 


// create WMS Atrina layer 
var wmslayer = new OpenLayers.Layer.WMS( 
"Atrina", 
" http://localhost:8080/geoserver/wms ", 
{'layers': 'DASSH:Atrina', 'format':'image/png', 'transparent':'true'}, 
{'opacity': 1.0, 'isBaseLayer': false, 'visibility': true} 
); 

map.addLayers([gmap, gsat, wmslayer]); 
map.addControl(new OpenLayers.Control.LayerSwitcher()); 
// Coordinate display at bottom of map 
map.addControl(new OpenLayers.Control.MousePosition()); 
map.setCenter(extent, 5); 

} _______________________________________________ 
Users mailing list 
[email protected] 
http://lists.osgeo.org/mailman/listinfo/openlayers-users 


_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to