clay.harter

WMS service always called with SRS=102100

Discussion created by clay.harter on Dec 21, 2013
I am trying to add a WMSLayer to a map initialized with an ESRI basemap.  The WMS service I am trying to use supports EPSG 3857 but not 102100. I am creating my WMSLayer by passing a resourceInfo so I don't need to do any proxy. But the WMS layer is not being returned because it is always being requested in 102100.  I have tried initializing my map with  an extent set in 3857 and have assigned a 3857 spatialReference  to my WMSLayer.

Is there any way I can intercept the generated WMS call and replace 102100 with 3857?

Or is there some other way to force the the WMS call to use 3857 rather than 102100?

Here is my simple test code:

<!DOCTYPE html>
<html> 
  <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
    <!--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://js.arcgis.com/3.7/js/dojo/dijit/themes/claro/claro.css"> 
    <link rel="stylesheet" href="http://js.arcgis.com/3.7/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://js.arcgis.com/3.7/"></script> 
    <script> 
      dojo.require("dijit.layout.BorderContainer");
      dojo.require("dijit.layout.ContentPane");
   dojo.require("esri.SpatialReference");
      dojo.require("esri.map");
      dojo.require("esri.layers.wms");
      
      var map;
      
      function init() { 
  var webMercator = new esri.SpatialReference(3857);
  var extent = new esri.geometry.Extent(200000,7000000,1200000,10200000, webMercator ) ; 
        map = new esri.Map("map", {
          basemap: "streets",
          extent: extent
        });
 
        var layer1 = new esri.layers.WMSLayerInfo({name:"Quadrants",title:"Quadrants"});
  var layer2 = new esri.layers.WMSLayerInfo({name:"Blocks",title:"Blocks"});
        var resourceInfo = {
          extent: new esri.geometry.Extent(200000,7000000,1200000,10200000, webMercator ) , 
          layerInfos: [layer1,layer2],
    version: "1.1.1",    
        };
  
        var wmsLayer = new esri.layers.WMSLayer("http://npdwms.npd.no/npdwmsmap_WGS84.asp",
          { 
   resourceInfo: resourceInfo,
   visibleLayers: ["Quadrants","Blocks"],
   spatialReference: webMercator    
          }
        ); 
        map.addLayers([wmsLayer]);
       
        var content = [];
        content.push("<b>Layers</b>:<ul>");
        dojo.forEach(wmsLayer.layerInfos, function(layerInfo) {
          content.push("<li>"  + layerInfo.title + "</li>");
        });
        content.push("</ul>");        
        dojo.byId('details').innerHTML = content.join("");
      }
      dojo.ready(init);
  
    </script> 
  </head> 
  
  <body class="claro"> 
    <div id="content" 
         data-dojo-type="dijit.layout.BorderContainer" 
         data-dojo-props="design:'headline', gutters:true" 
         style="width: 100%; height: 100%; margin: 0;"> 

      <div id="details" 
           data-dojo-type="dijit.layout.ContentPane" 
           data-dojo-props="region:'left', splitter:true" 
           style="overflow:auto; width:200px;" > 
      </div> 

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

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

Outcomes