API version 3.3 and WMS layers not working, CRS missing

777
3
01-13-2013 11:52 PM
JohnnyPenet
New Contributor
Hi,

Changing from API 3.2 to 3.3,using WMS layers no longer worked. The base layer has a spatial reference of 31370 and my WMS layers has the same spatial reference. Using Fiddler I noticed that CRS is no longer provided using the REST service getmap.
In version 3.2 the WMS layers worked and the CRS is provided. In both case I used the resourceInfo option and no proxy is used.

Has someone any idea what has been changed in 3.3 for using WMS layers?
0 Kudos
3 Replies
KellyHutchins
Esri Frequent Contributor
I tested this out using the WMS sample in the help and it works ok there:

http://help.arcgis.com/en/webapi/javascript/arcgis/samples/layers_wmsresourceinfo/index.html

Can you post your code?
0 Kudos
JohnnyPenet
New Contributor
Kelly,

This is the code I use. One of the wms layers I use to test is http://grb.agiv.be/geodiensten/raadpleegdiensten/GRB/wms
With 3.2 this works fine, with 3.3 it fails, no CRS . Spatial reference is 31370
I added extent at two places, add the version, but if still fails. As you can see all loading happens dynamically.
I also added a log file maintained by the application. There you can see the URL generated for the WMS.

Kind Regards

Johnny

var resourceInfo = {
extent: new esri.geometry.Extent(baseLayer.WmsExtent.xmin, baseLayer.WmsExtent.ymin, baseLayer.WmsExtent.xmax, baseLayer.WmsExtent.ymax,
{
     wkid: baseLayer.WmsExtent.spatialReference
}),
layerInfos: layerInfos
};
mapLayer = new esri.layers.WMSLayer(baseLayer.RESTURL,{
        resourceInfo: resourceInfo,
        extent: new esri.geometry.Extent(baseLayer.WmsExtent.xmin, baseLayer.WmsExtent.ymin, baseLayer.WmsExtent.xmax, baseLyer.WmsExtent.ymax,
  { wkid: baseLayer.WmsExtent.spatialReference }),
        visibleLayers: layerNames
});
mapLayer.setImageFormat("png");
mapLayer.version = "1.3.0";
mapLayer.spatialReference = new esri.SpatialReference({
        "wkid": baseLayer.WmsExtent.spatialReference
});
handle = dojo.connect(mapLayer, "onError", function (err) {
        dojo.disconnect(handle);
        if (err.message)
              logging.logMessage("I", "*E* wmslayer  initialize process failed. " + err.name + " - " + err.message, "gisOperation/_addNewWmsLayer");
        else
              logging.logMessage("I", "*E* wmslayer  initialize process failed. " + err, "gisOperation/_addNewWmsLayer");
});
try {
        map.addLayers([mapLayer]);
} catch (e) {
        logging.logMessage("E", "wmslayer " + baseLayer.RESTURL + " add layer error. " + e.name + " - " + e.message, "gisOperation/_addNewWmsLayer");
};


Logging of the system

14/01/2013 - 18:29:58 - I - startup - getconfiguration start
14/01/2013 - 18:29:58 - I - startup - startup finished
14/01/2013 - 18:29:59 - I - addNewDynamicLayer - http://gisservices.inbo.be/ArcGIS/rest/services/Orthofoto/MapServer
14/01/2013 - 18:30:00 - I - mapModule - init finished
14/01/2013 - 18:30:00 - I - layer_Initialized - http://gisservices.inbo.be/ArcGIS/rest/services/Orthofoto/MapServer
14/01/2013 - 18:30:00 - I - mapModule - init - onload
14/01/2013 - 18:30:00 - I - addNewWmsLayer - http://grb.agiv.be/geodiensten/raadpleegdiensten/GRB/wms
14/01/2013 - 18:30:00 - I - addNewWmsLayer - http://wms.agiv.be/inspire/wms/adressen
14/01/2013 - 18:30:00 - I - addNewFeatureLayer - http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/1
14/01/2013 - 18:30:00 - I - addNewFeatureLayer - http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/2
14/01/2013 - 18:30:00 - I - gisOperation/_addNewWmsLayer - *E* wmslayer  initialize process failed. Error - Kan afbeelding niet laden: http://grb.agiv.be/geodiensten/raadpleegdiensten/GRB/wms?SERVICE=WMS&REQUEST=GetMap&FORMAT=image/png...
14/01/2013 - 18:30:00 - I - featureLayer_Initialized - http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/1
14/01/2013 - 18:30:00 - I - featureLayer_Initialized - verify end of layers loaded  - http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/1
14/01/2013 - 18:30:00 - I - featureLayer_Initialized - http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/2
14/01/2013 - 18:30:00 - I - featureLayer_Initialized - verify end of layers loaded  - http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/2
14/01/2013 - 18:30:00 - I - All layers initialized. - verifyInitialisationMap
14/01/2013 - 18:30:00 - I - All layers added to the map. - verifyInitialisationMap
14/01/2013 - 18:30:00 - I - mapModule - execute mapLoaded
14/01/2013 - 18:30:00 - I - mapModule - init - initEditing
14/01/2013 - 18:30:01 - I - eventAggregator-publish - mapLoaded - legendBuild
14/01/2013 - 18:30:01 - I - legendModule - start legend build
14/01/2013 - 18:30:01 - I - legendModule - build legend done
14/01/2013 - 18:30:01 - I - eventAggregator-publish - legendBuild - selectBuild
14/01/2013 - 18:30:01 - I - layerSelectionModule - start layer selection build
14/01/2013 - 18:30:01 - I - layerSelectionModule - end layer selection build
0 Kudos
KellyHutchins
Esri Frequent Contributor
Hi Johnny,

I ran a simple test using a proxy and an ArcGIS.com basemap and was able to add your wms layer at both 3.2 and 3.3. I know that your scenario is quite different in that it sounds like you have a basemap in the same Spatial Reference as the wms layer and you aren't using the proxy.

I did a quick search and can't find a test basemap in the spatial reference you are using. Could you modify the test code below so that it reproduces the issue?
<!DOCTYPE html>
<html> 
  <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9">
    <!--The viewport meta tag is used to improve the presentation and behavior of the samples 
      on iOS devices-->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>Map with WMS</title> 

    <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/js/dojo/dijit/themes/claro/claro.css"> 
    <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/js/esri/css/esri.css">
    <style> 
      html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
    </style> 

    <script>var dojoConfig = {parseOnLoad: true};</script> 
    <script src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/"></script> 
    <script> 
      dojo.require("dijit.layout.BorderContainer");
      dojo.require("dijit.layout.ContentPane");
      dojo.require("esri.map");
      dojo.require("esri.layers.wms");
      
      var map;
      var wmsLayer;

 
      function init() {
        map = new esri.Map("map",{
            extent: new esri.geometry.Extent({"xmin":-89257.57663483504,"ymin":6286122.683888868,"xmax":1196107.491008342,"ymax":6908625.842243175,"spatialReference":{"wkid":102100}})
        });
        esri.config.defaults.io.proxyUrl = "http://localhost/proxy/proxy.ashx";
        
        var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");

        dojo.connect(map, "onLoad", function(){
            wmsLayer = new esri.layers.WMSLayer("http://grb.agiv.be/geodiensten/raadpleegdiensten/GRB/wms");
            wmsLayer.setVisibleLayers([0,1]);
            wmsLayer.setImageFormat("png");
         
            map.addLayer(wmsLayer);

        });
             
        map.addLayer(basemap);
        
      }

      dojo.ready(init);
    </script> 
  </head> 
  
  <body class="claro"> 
    <div id="content" 
         data-dojo-type="dijit.layout.BorderContainer" 
         data-dojo-props="design:'headline', gutters:false" 
         style="width: 100%; height: 100%; margin: 0;"> 

      <div id="map" 
           data-dojo-type="dijit.layout.ContentPane" 
           data-dojo-props="region:'center'" 
           style="overflow:hidden;"> 
      </div> 

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

0 Kudos