AnsweredAssumed Answered

WMS Layer from external server (via Custom WMS / WMS resource info)

Question asked by Striewski on Nov 11, 2015
Latest reply on Nov 13, 2015 by joshhevenor

I try to add a WMS layer to an ESRI basemap, following the templates of Custom WMS or WMS resource info. As result I get the basemap displayed properly but the WMS layer is missing. Honestly I have no idea what I am doing wrong.

 

GetCapabilites:

http://nibis.lbeg.de/net3/public/ogc.ashx?PkgId=24&Version=1.1.1&Service=WMS&Request=GetCapabilities

 

My request is:

http://nibis.lbeg.de/net3/public/ogc.ashx?PkgId=22&Version=1.1.1&Service=WMS&Request&Service=WMS&Request=GetMap&Layers=L…

 

Translated into the "WMS Resource Info" template, I highlighted the relevant parts:

  <script>

    var map;

    require([

      'esri/map', 'esri/layers/WMSLayer', 'esri/layers/WMSLayerInfo', 'esri/geometry/Extent',

      'dojo/_base/array', 'dojo/dom', 'dojo/dom-construct', 'dojo/parser',

      'dijit/layout/BorderContainer', 'dijit/layout/ContentPane', 'dojo/domReady!'

    ], function(Map, WMSLayer, WMSLayerInfo, Extent, array, dom, domConst, parser) {

      parser.parse();

 

 

 

      map = new Map('map', {

        basemap: 'satellite',

        center: [10.56, 51.738],

        zoom: 12

      });

 

 

 

      var layer1 = new WMSLayerInfo({

        name: 'L23',

 

 

        title: 'Geo'

      });

 

      var layer2 = new WMSLayerInfo({

        name: '2',

        title: 'Cities'

      });

 

      var resourceInfo = {

        version: "1.1.1",

        format: "png",

        extent: new Extent(728861,6661184,1307070,7157726, {

          wkid: 3857

        }),

        layerInfos: [layer1, layer2]

      };

 

      var wmsLayer = new WMSLayer('http://nibis.lbeg.de/net3/public/ogc.ashx?', {

        resourceInfo: resourceInfo,

        visibleLayers: ['L23', '2']

      });

 

      map.addLayers([wmsLayer]);

  

      var details = dom.byId('details');

      domConst.place('<b>Layers</b>:', details);

      var ul = domConst.create('ul', null, details);

      array.forEach(wmsLayer.layerInfos, function(layerInfo) {

        domConst.create('li', { innerHTML: layerInfo.title }, ul);

      });

      domConst.place('<b>WMS Version</b>:' + wmsLayer.version + '<br />', details);

    });

  </script>

 

Same with "Custom Layer - WMS":

 

    <script>

      dojo.require("esri.map");

      var map;

 

 

      dojo.ready(function() {

        dojo.declare("my.GeoLayer", esri.layers.DynamicMapServiceLayer, {

          constructor: function() {

            this.initialExtent = this.fullExtent =    new esri.geometry.Extent({"xmin":728861,"ymin":6661184,"xmax":1307070,"ymax":7157726,"spatialReference":{"wkid":102100}});

            this.spatialReference = new esri.SpatialReference({wkid:102100});

 

 

            this.loaded = true;

            this.onLoad(this);

          },

 

 

          getImageUrl: function(extent, width, height, callback) {

            var params = {

              request:"GetMap",

              transparent:true,

              format:"image/png",

              bgcolor:"ffffff",

              version:"1.1.1",

              layers:"L23",

              styles: "default,default",

              exceptions: "application/vnd.ogc.se_xml",

 

 

              //changing values

              bbox:extent.xmin + "," + extent.ymin + "," + extent.xmax + "," + extent.ymax,

              srs: "EPSG:" + extent.spatialReference.wkid,

              width: width,

              height: height

            };

 

 

            callback("http://nibis.lbeg.de/net3/public/ogc.ashx?" + dojo.objectToQuery(params));

          }

        });

      });

 

 

      function init() {

        map = new esri.Map("map", {

          basemap: "satellite",

          center: [10.56, 51.738],

          zoom: 10

        });

 

 

        map.addLayer(new my.GeoLayer());

      }

 

 

      dojo.ready(init);

    </script>

Outcomes