Fakhar uz Zaman
Fakhar uz Zaman

Reputation: 299

GeoServer Request not working

I am trying to add map into my web page. Shapefiles are uploaded/published in GeoServer. When request is made, not map is displayed in webpage. Following is code.

<html>
<head>
<script type="text/javascript" src="OpenLayers.js"></script>
<script type="text/javascript">

    var map;

    function init() {
        map = new OpenLayers.Map('map');
        var wms = new OpenLayers.Layer.WMS(
        "OpenLayers WMS",
        "http://localhost:8080/geoserver/New_York_Roads/wms",
        { layers: 'basic' }
        );

        map.addLayers([wms]);
        map.zoomToMaxExtent();
    }

</script>
</head>

<body onload="init()">
<div id="map" style="width: 600px; height: 300px">

</div>
</body>
</html>

Upvotes: 0

Views: 151

Answers (1)

ylka
ylka

Reputation: 293

change this line:

   map.addLayers([wms]);

to this:

    map.addLayer(wms);

more info here

Upvotes: 1

Related Questions