[OpenLayers-Users] Trouble getting mapserver WMS layer to load
in OL
Arnd Wippermann
arnd.wippermann at web.de
Wed Apr 30 13:33:35 EDT 2008
Hi Roger,
you must declare the right projection for your map. Without any option the
projection OpenLayers will use is EPSG:4326 with -180,-90,180,90 as extent.
So the response of the WMS request is all right, if you get blank tiles.
Try something like this:
var options = {
projection: "EPSG:2286",
//perhaps also
//maxResolution: ....
units: "m",
maxZoomLevel : 16,
//if set you must add your controls manuel after the map declaration
//controls : [],
numZoomLevels : 16,
//this is a guess
maxExtent: new OpenLayers.Bounds(500000, 500000, 1000000, 1000000)
};
map = new OpenLayers.Map('map', options);
With maxResolution I am not all clear. I always set it. For Google it is
156543.0339.
Mit freundlichen Grüssen
Arnd Wippermann
http://gis.ibbeck.de/ginfo/
_____
Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von Roger André
Gesendet: Mittwoch, 30. April 2008 03:49
An: users at openlayers.org
Betreff: [OpenLayers-Users] Trouble getting mapserver WMS layer to load in
OL
Hi,
I'm a new user of Mapserver and am having a hard time with getting layers
from a new mapfile to load in OpenLayers. I've tested that my local
mapserver install is responding correctly to WMS requests, and it seems to
work correctly. Here is the request, with some linebreaks for clarity;
http://localhost/cgi-bin/mapserv?map=/var/www/520_webmap/mapfiles/520_ECP.ma
p
&SERVICE=WMS
&version=%221.1.122
&REQUEST=GetMap
&LAYERS=Wetlands
&STYLES=
&BBOX=775843.302946,602429.871045,848438.746010,635418.446144
&WIDTH=600
&HEIGHT=400
&FORMAT=png
&SRS=epsg:2286
This returns an image that contains all of the layers which are active at
the scale of the BBOX area. However, I cannot seem to find the right syntax
to get the layer to load into OpenLayers. I have taken one of the test.html
files, the one for a single wms, and have tested that it works with my
openlayers.js install. This is that file:
-----------------------
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>OpenLayers Basic Single WMS Example</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css"
/>
<style type="text/css">
#map {
width: 512px;
height: 512px;
border: 1px solid black;
}
</style>
<script
src="http://localhost:8080/geoserver/www/openlayers/OpenLayers.js"></script>
<script type="text/javascript">
var map, layer;
function init(){
map = new OpenLayers.Map( 'map' );
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0",
{layers: 'basic'} );
map.addLayer(layer);
map.zoomToMaxExtent();
}
</script>
</head>
<body onload="init()">
<h1 id="title">Basic Single WMS Example</h1>
<div id="tags"></div>
<div id="shortdesc">Show a Simple Map</div>
<div id="map"></div>
<div id="docs">
This example shows a very simple layout with minimal controls. This
example uses a single WMS base layer.
</div>
</body>
</html>
------------------------------
No matter how I edit the file though, when I point to my localhost mapserver
instance, I just get an empty map frame, with no map controls, or anything
inside of it. Right now the layer portion looks like this:
<script type="text/javascript">
var map, layer;
function init(){
map = new OpenLayers.Map('map',
{ maxExtent: new
OpenLayers.Bounds(775843.302946,602429.871045,848438.746010,635418.446144),
maxResolution: "auto",
projection:"SRS_not_defined"
} );
layer = new OpenLayers.Layer.WMS( '520_WebMap',
"http://localhost/cgi-bin/mapserv?",
{ layers: 'Wetlands',
map:
'map=/var/www/520_webmap/mapfiles/520_ECP.map',
format: 'image/png',
request: 'getmap',
transparent: "false"
});
map.addLayer(layer);
map.zoomToMaxExtent();
</script>
I'm hoping one of you has encountered a similar problem and can give me some
advice for how to resolve it.
Thanks,
Roger
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080430/07f596c4/attachment.html
More information about the Users
mailing list