openlayers - wms - map not loading

user1173933 picture user1173933 · Jan 27, 2012 · Viewed 7.1k times · Source

I've created a simple site with a map where I'm connecting to a wms-server. The problem is now, that the map isn't shown, just a view small pictures. Here is the site i've created: http://dl.dropbox.com/u/2418858/index.html

Here is the code i've been using:

<script type="text/javascript">
        var map;
        var wms;
        var map_controls = [new OpenLayers.Control.LayerSwitcher(),
                             new OpenLayers.Control.PanZoomBar(), 
                             new OpenLayers.Control.MouseToolbar(), 
                             new OpenLayers.Control.KeyboardDefaults()];

        function init() {
            map = new OpenLayers.Map("map", {
                controls : map_controls
            });
            wms = new OpenLayers.Layer.WMS("Satellitenbild_30m", "http://gis.lebensministerium.at/wmsgw/", {
                layers : 'Satellitenbild_30m',
                key : '6ae2a41178c77ccee1db7248c9f92b04',
            }, {
                projection : new OpenLayers.Projection('EPSG:32632'),
                singleTile : true,
                buffer : 0,
                ratio : 1
            });

            map.addLayer(wms);

            map.zoomToMaxExtent();

        }
    </script>
</head>
<body onload=init()>
    <div id="map" style="width: 1000px; height: 1000px"></div>
    </div>
</body>

When I'm using Spatial commander (a GIS-desktop-program) I'm seeing the map and can zoom-in and out, but when I'm using Openlayers I don't see a map.

So what I've done is intercepting the request vom Spatial Commander with a proxy to see how this request differs from mine sent from my website.

The only difference I've found was the BBOX parameter which in SC looked like this:

BBOX=495149.712089618,4954209.6147000715,1173065.9355847104,5633477.615310807

and the parameter in a request sent from my webpage looked like this:

BBOX=-351.5625,-351.5625,351.5625,351.5625

So I changed the BBOX parameter sent through my webpage manually and get this: manual request So there was the map!

Now my actual questions:

  • Why is'nt the map showing on my website?
  • Why is the BBOX-parameter sent automatically from Openlayers so far off the values sent from spatial commander?
  • How can I make my map work?

Thanks!

Answer

Chau picture Chau · Jan 30, 2012

Try setting the property maxResolution on the map object:

map = new OpenLayers.Map("map", {
    controls : map_controls,
    maxResolution: 1000
});