3

I am unable to figure out why I can't add WMS in OL3? Tiger is a default layer in Geoserver.

Below my code.

Open Street Map

</head>

<div id="map" class="map"></div>
<div id="info">&nbsp;</div>
 <div id="overlay" style="background-color: white; border-radius: 10px; border: 1px solid black; padding: 5px 10px;">


<script>

        var wmsSource =new ol.source.ImageWMS({
        url:'http://localhost:8080/geoserver/tiger/wms',
        params: {'LAYERS':'tiger:tiger_roads'},
        serverType:'geoserver',
        crossOrigin: 'anonymous'
        });

        var wmsLayer=new ol.layer.Image({
        source:wmsSource
        });

           var view = new ol.View({
            center: [0, 0],
            zoom: 1
            });

            var map = new ol.Map({
            layers: [wmsLayer],
            target: 'map',
            view: view
            });

6

1 Answer 1

1

Change

 var view = new ol.View({
        center: [0,0],
        zoom: 1
        });

to

 var view = new ol.View({
        center: [-8208266.719431938, 4979872.392779233],
        zoom: 11
        });

Now you can see the WMS layer....

1
  • Please , could you tell me where I can find information about center ?
    – Agnieszka
    Commented Feb 25, 2016 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.