[OpenLayers-Users] Trouble getting mapserver WMS layer to load in OL

Roger André randre at gmail.com
Tue Apr 29 21:48:49 EDT 2008


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.map
&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/20080429/f72f35c8/attachment.html


More information about the Users mailing list