0

Adding two layers using OpenLayers, one map layer from OSM, second layer adding from GeoServer localhost. But when I load single OSM layer it's showing by default map.

It's okay, but when adding second layer it's not working. it's also disappear old layer map also and when I remove first layer it's won't show anything from second layer

var MapLayer = new ol.layer.Tile({
            source: new ol.source.OSM()
        });
        var myView = new ol.View({
            center: [74.1296577, 32.2739606],
            zoom: 4,
            projection: projection
        });
        var mymap = new ol.source.TileWMS({
            url: 'http://localhost:8080/geoserver/DHAGIS/wms',
            params: { 'LAYERS': 'DHAGIS:baddoki', 'TILED': true, 'STYLES': 'graves' },
            serverType: 'geoserver',

        });
        var mylayer = new ol.layer.Tile({
            source=mymap
        });
        //////////////////////////
        var map = new ol.Map({
            target: 'map',
            layers: [MapLayer, mylayer
            ],
            view: myView
        });
  • What's in Geoserver's log (in verbose mode) after you make the GetMap request ? Can you preview the layer with Geoserver's built-in preview ? – Olyster May 21 at 17:51
  • source=mymap should be source: mymap – Mike May 21 at 19:15
  • We need to check the console, on the browser, using the development tools. You will find the errors displayed on the console. – jgrocha May 21 at 22:01
  • Mike i already changed source=mymap like source: mymap – user143395 May 22 at 7:34
  • and layer preview in geoserver working fine but when i try to access inside my web application its showing nothing – user143395 May 22 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.