2

I am currently trying to get OpenLayers to show a WMS-Layer. Doing this I encounter a problem I am not able to solve. This might even be a bug in OpenLayers, but before filling an appropriate bugreport at their tracking system I would like to make shure that the mistake is not mine.

This is a minimal example producing the error:

<html>
<head>
    <script src="../javascript/openlayers/lib/OpenLayers.js"></script>
</head>
<body>
    <div style="width:100%; height:100%" id="map"></div>
    <script defer="defer" type="text/javascript">
        var map = new OpenLayers.Map( 'map' );

        var layer = OpenLayers.Layer.WMS( "mymap", 
                                          "http://192.168.1.1/cgi-bin/mapserv",
                                          {layers: 'buildings', map: 'map=/var/public/maps/mapfile.map'}
                    );
        map.addLayer(layer);
        map.zoomToMaxExtent();
    </script>
</body>
</html>

This gives the error

this.addOptions is not a function

using Firefox 5.0 with Ubuntu Natty.

I also could provide the corresponding mapfile, but the error looks like JavaScript-Problems to me thus I will spare you the details as long as nobody requests it.

Thank you for your support and ideas.

Thilo
  • 8,827
  • 2
  • 35
  • 56

1 Answers1

9

Well, the OpenLayers-Users-Mailinlist, or better Bart van den Eijnden, provided the answer - which I am a bit ashamed of posting... Anyways:

You are missing the new keyword in front of OpenLayers.Layer.WMS.

Thilo
  • 8,827
  • 2
  • 35
  • 56