开发者

Openlayers: this.addOptions is not a function

开发者 https://www.devze.com 2023-03-31 10:33 出处:网络
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 bugrepor

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 N开发者_如何学运维atty.

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消