<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Problem display with WMS and WMTS in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-display-with-wms-and-wmts/m-p/1212578#M78714</link>
    <description>&lt;P&gt;The issue you're running into is the same underlying issue discussed &lt;A href="https://community.esri.com/t5/arcgis-api-for-javascript-questions/wraparound180-bug/td-p/601620" target="_self"&gt;here&lt;/A&gt;: the 3.x API can have problems with tiled layers when the first layer added to the map is not tiled.&amp;nbsp; The solution is to define the map's tiling info up front.&lt;/P&gt;&lt;P&gt;Try this instead, which would replace your current call to "require":&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    require([
      "esri/map","esri/SpatialReference", "esri/geometry/Extent", "esri/layers/WMSLayer", "esri/layers/WMSLayerInfo", "esri/layers/WMTSLayer", "esri/layers/WMTSLayerInfo",
      "esri/config", "esri/layers/TileInfo", "esri/geometry/Point",
      "dojo/domReady!"
    ], function(
      Map, SpatialReference, Extent, WMSLayer,WMSLayerInfo, WMTSLayer, WMTSLayerInfo,
      esriConfig, TileInfo, Point
    ) {
      var extent3857 = new Extent({
          xmin: 612056.7798435382,
          ymin: 5682778.707431033,
          xmax: 822811.5409472634,
          ymax: 5780363.363667572,
          spatialReference: { wkid: 102100, latestWkid: 3857 }
        });

      var extent4326 = new Extent({
          xmin: 5.7238,
          ymin: 45.6390,
          xmax: 5.984802,
          ymax: 45.828799,
          spatialReference: { wkid: 4326 }
        });

      esriConfig.defaults.io.proxyUrl = "/AP_voirie/web/kernel/proxy/proxy.ashx";

      map = new Map("map", {
        
        extent:extent3857,//pseudo mercator,
        zoom: 13
      });

	  var tileInfo = new TileInfo({
		dpi: 96,
		height: 256,
		lods: [
			{
				level: 0,
				resolution: 156543.033928,
				scale: 591657527.591555
			},
			{
				level: 1,
				resolution: 78271.5169639999,
				scale: 295828763.795777
			},
			{
				level: 2,
				resolution: 39135.7584820001,
				scale: 147914381.897889
			},
			{
				level: 3,
				resolution: 19567.8792409999,
				scale: 73957190.948944
			},
			{
				level: 4,
				resolution: 9783.93962049996,
				scale: 36978595.474472
			},
			{
				level: 5,
				resolution: 4891.96981024998,
				scale: 18489297.737236
			},
			{
				level: 6,
				resolution: 2445.98490512499,
				scale: 9244648.868618
			},
			{
				level: 7,
				resolution: 1222.99245256249,
				scale: 4622324.434309
			},
			{
				level: 8,
				resolution: 611.49622628138,
				scale: 2311162.217155
			},
			{
				level: 9,
				resolution: 305.748113140558,
				scale: 1155581.108577
			},
			{
				level: 10,
				resolution: 152.874056570411,
				scale: 577790.554289
			},
			{
				level: 11,
				resolution: 76.4370282850732,
				scale: 288895.277144
			},
			{
				level: 12,
				resolution: 38.2185141425366,
				scale: 144447.638572
			},
			{
				level: 13,
				resolution: 19.1092570712683,
				scale: 72223.819286
			},
			{
				level: 14,
				resolution: 9.55462853563415,
				scale: 36111.909643
			},
			{
				level: 15,
				resolution: 4.77731426794937,
				scale: 18055.954822
			},
			{
				level: 16,
				resolution: 2.38865713397468,
				scale: 9027.977411
			},
			{
				level: 17,
				resolution: 1.19432856685505,
				scale: 4513.988705
			},
			{
				level: 18,
				resolution: 0.59716428355981721,
				scale: 2256.994353
			},
			{
				level: 19,
				resolution: 0.29858214164761665,
				scale: 1128.4971760000001
			},
			{
				level: 20,
				resolution: 0.1492910708899543,
				scale: 564.248588
			},
			{
				level: 21,
				resolution: 0.0746455354449772,
				scale: 282.124294
			},
			{
				level: 22,
				resolution: 0.0373227677224886,
				scale: 141.062147
			},
			{
				level: 23,
				resolution: 0.0186613838612443,
				scale: 70.5310735
			},
			{
				level: 24,
				resolution: 0.0093306919306222,
				scale: 35.26553675
			}
		],
		origin: new Point(-20037508.342787, 20037508.342787, new SpatialReference(3857)),
		spatialReference: new SpatialReference(3857),
		width: 256
	  });

	  map._params.tileInfo = tileInfo;
	  map.__tileInfo = tileInfo;

      dojo.connect(map, "onLoad", function ()
      {
        console.log("maponload");
        //ignWmsLayer.spatialReference = { wkid: 102100, latestWkid: 3857 }  ;
        //ignWmtsLayer.spatialReference = { wkid: 102100, latestWkid: 3857 }  ;

        //ignWmsLayer.spatialReferences[0] = 3857;
        console.log(ignWmsLayer.spatialReferences);
        console.log("spatialReference esriLayer  : " ,  esriLayer.spatialReference);
        console.log("spatialReference ignwms : " ,  ignWmsLayer.spatialReference);
        console.log("spatialReference ignWmtsLayer  : " , ignWmtsLayer.spatialReference);
      });

      var aLayers = [];

      // ESRI basemaps
      var strEsriUrl = "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer";
      esriLayer = new esri.layers.ArcGISTiledMapServiceLayer(strEsriUrl);

      // IGN basemaps 

      // WMS
      // https://wxs.ign.fr/cartes/geoportail/r/wms?request=GetCapabilities&amp;amp;service=WMS
      // Premier systeme de coordonnées de référence : CRS:84 comment le changer au chargement 
      var strIgnWmsUrl = "https://wxs.ign.fr/cartes/geoportail/r/wms";

      /*
      Test avec Layer info
      var WMSLayerInfo1 =  new esri.layers.WMSLayerInfo({
        name: 'SCANREG_PYR-JPEG_WLD_WM',
        title: 'SCANREG_PYR-JPEG_WLD_WM',
        spatialReferences : [3857]  
      });

      var resourcesInfo = {
          layerInfos: [WMSLayerInfo1],
          spatialReferences : [3857],
          extent: extent3857

      };

      ignWmsLayer = new esri.layers.WMSLayer(strIgnWmsUrl, {
            format: "jpeg",
            minScale: 100000000,
            maxScale: 200,
            resourceInfo : resourcesInfo,
            visibleLayers: ["SCANREG_PYR-JPEG_WLD_WM"],
            transparent: true,
            id: "WMS ScanRegion"
          });
      
      */

      ignWmsLayer = new esri.layers.WMSLayer(strIgnWmsUrl, {
              format: "jpeg",
              minScale: 100000000,
              maxScale: 200,
              visibleLayers: ["SCANREG_PYR-JPEG_WLD_WM"],
              transparent: true,
              id: "WMS ScanRegion"
      });

      // WMTS
      // https://wxs.ign.fr/ortho/geoportail/wmts?request=GetCapabilities&amp;amp;service=WMTS&amp;amp;version=1.0.0
      var strIgnWmtsUrl = "https://wxs.ign.fr/ortho/geoportail/wmts";
      
      var layerInfo =  new esri.layers.WMTSLayerInfo({
              identifier: "ORTHOIMAGERY.ORTHOPHOTOS",
              tileMatrixSet: "PM",
              format: "jpeg"
      });
      var ignOptions = {
              serviceMode: "KVP",
              minScale: 100000000,
              maxScale: 200,
              layerInfo: layerInfo
      };

      ignWmtsLayer = new esri.layers.WMTSLayer(strIgnWmtsUrl, ignOptions);

      // Add layers to array
      
      // esri first one =&amp;gt; OK it works
      /*aLayers.push(esriLayer);
      aLayers.push(ignWmtsLayer);
      aLayers.push(ignWmsLayer);*/

      // wmts first one =&amp;gt; OK it works
      /*aLayers.push(ignWmtsLayer);
      aLayers.push(ignWmsLayer);
      aLayers.push(esriLayer);*/

      // wms first one =&amp;gt; NO it doesn't work =&amp;gt; how change CRS WMS in spatialreferences ?
      aLayers.push(ignWmsLayer);
      aLayers.push(ignWmtsLayer);
      aLayers.push(esriLayer);

      // setVisibility first layer
      for (let index = 0; index &amp;lt; aLayers.length; index++) {
        let layer = aLayers[index];
        if (index == 0) layer.setVisibility(true);
        else layer.setVisibility(false);
      }
  
      // Add basemaps layers
      map.addLayers(aLayers);
    });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Sep 2022 18:02:29 GMT</pubDate>
    <dc:creator>JoelBennett</dc:creator>
    <dc:date>2022-09-14T18:02:29Z</dc:date>
    <item>
      <title>Problem display with WMS and WMTS</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-display-with-wms-and-wmts/m-p/1212317#M78705</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Depending on the order of raster backgrounds specified for the map,&lt;BR /&gt;the WMTS service is not displayed when the first layer is the IGN WMS service.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Apparently the problem comes from the fact that the capabilities service returns the&lt;BR /&gt;&amp;lt;CRS&amp;gt;CRS:84&amp;lt;/CRS&amp;gt; first but not 3857 but how to change it ?&lt;/P&gt;&lt;P&gt;My sample code for test (see join file wms_wmts_ign_arcgis.zip)&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp; // Add layers to array&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // esri first one =&amp;gt; OK it works&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; /*aLayers.push(esriLayer);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; aLayers.push(ignWmtsLayer);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; aLayers.push(ignWmsLayer);*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // wmts first one =&amp;gt; OK it works&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; /*aLayers.push(ignWmtsLayer);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; aLayers.push(ignWmsLayer);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; aLayers.push(esriLayer);*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // wms first one =&amp;gt; NO it doesn't work =&amp;gt; how change CRS WMS in spatialreferences ?&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; aLayers.push(ignWmsLayer);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; aLayers.push(ignWmtsLayer);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; aLayers.push(esriLayer);&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 08:50:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-display-with-wms-and-wmts/m-p/1212317#M78705</guid>
      <dc:creator>LionelGOUBET</dc:creator>
      <dc:date>2022-09-14T08:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: Problem display with WMS and WMTS</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-display-with-wms-and-wmts/m-p/1212578#M78714</link>
      <description>&lt;P&gt;The issue you're running into is the same underlying issue discussed &lt;A href="https://community.esri.com/t5/arcgis-api-for-javascript-questions/wraparound180-bug/td-p/601620" target="_self"&gt;here&lt;/A&gt;: the 3.x API can have problems with tiled layers when the first layer added to the map is not tiled.&amp;nbsp; The solution is to define the map's tiling info up front.&lt;/P&gt;&lt;P&gt;Try this instead, which would replace your current call to "require":&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    require([
      "esri/map","esri/SpatialReference", "esri/geometry/Extent", "esri/layers/WMSLayer", "esri/layers/WMSLayerInfo", "esri/layers/WMTSLayer", "esri/layers/WMTSLayerInfo",
      "esri/config", "esri/layers/TileInfo", "esri/geometry/Point",
      "dojo/domReady!"
    ], function(
      Map, SpatialReference, Extent, WMSLayer,WMSLayerInfo, WMTSLayer, WMTSLayerInfo,
      esriConfig, TileInfo, Point
    ) {
      var extent3857 = new Extent({
          xmin: 612056.7798435382,
          ymin: 5682778.707431033,
          xmax: 822811.5409472634,
          ymax: 5780363.363667572,
          spatialReference: { wkid: 102100, latestWkid: 3857 }
        });

      var extent4326 = new Extent({
          xmin: 5.7238,
          ymin: 45.6390,
          xmax: 5.984802,
          ymax: 45.828799,
          spatialReference: { wkid: 4326 }
        });

      esriConfig.defaults.io.proxyUrl = "/AP_voirie/web/kernel/proxy/proxy.ashx";

      map = new Map("map", {
        
        extent:extent3857,//pseudo mercator,
        zoom: 13
      });

	  var tileInfo = new TileInfo({
		dpi: 96,
		height: 256,
		lods: [
			{
				level: 0,
				resolution: 156543.033928,
				scale: 591657527.591555
			},
			{
				level: 1,
				resolution: 78271.5169639999,
				scale: 295828763.795777
			},
			{
				level: 2,
				resolution: 39135.7584820001,
				scale: 147914381.897889
			},
			{
				level: 3,
				resolution: 19567.8792409999,
				scale: 73957190.948944
			},
			{
				level: 4,
				resolution: 9783.93962049996,
				scale: 36978595.474472
			},
			{
				level: 5,
				resolution: 4891.96981024998,
				scale: 18489297.737236
			},
			{
				level: 6,
				resolution: 2445.98490512499,
				scale: 9244648.868618
			},
			{
				level: 7,
				resolution: 1222.99245256249,
				scale: 4622324.434309
			},
			{
				level: 8,
				resolution: 611.49622628138,
				scale: 2311162.217155
			},
			{
				level: 9,
				resolution: 305.748113140558,
				scale: 1155581.108577
			},
			{
				level: 10,
				resolution: 152.874056570411,
				scale: 577790.554289
			},
			{
				level: 11,
				resolution: 76.4370282850732,
				scale: 288895.277144
			},
			{
				level: 12,
				resolution: 38.2185141425366,
				scale: 144447.638572
			},
			{
				level: 13,
				resolution: 19.1092570712683,
				scale: 72223.819286
			},
			{
				level: 14,
				resolution: 9.55462853563415,
				scale: 36111.909643
			},
			{
				level: 15,
				resolution: 4.77731426794937,
				scale: 18055.954822
			},
			{
				level: 16,
				resolution: 2.38865713397468,
				scale: 9027.977411
			},
			{
				level: 17,
				resolution: 1.19432856685505,
				scale: 4513.988705
			},
			{
				level: 18,
				resolution: 0.59716428355981721,
				scale: 2256.994353
			},
			{
				level: 19,
				resolution: 0.29858214164761665,
				scale: 1128.4971760000001
			},
			{
				level: 20,
				resolution: 0.1492910708899543,
				scale: 564.248588
			},
			{
				level: 21,
				resolution: 0.0746455354449772,
				scale: 282.124294
			},
			{
				level: 22,
				resolution: 0.0373227677224886,
				scale: 141.062147
			},
			{
				level: 23,
				resolution: 0.0186613838612443,
				scale: 70.5310735
			},
			{
				level: 24,
				resolution: 0.0093306919306222,
				scale: 35.26553675
			}
		],
		origin: new Point(-20037508.342787, 20037508.342787, new SpatialReference(3857)),
		spatialReference: new SpatialReference(3857),
		width: 256
	  });

	  map._params.tileInfo = tileInfo;
	  map.__tileInfo = tileInfo;

      dojo.connect(map, "onLoad", function ()
      {
        console.log("maponload");
        //ignWmsLayer.spatialReference = { wkid: 102100, latestWkid: 3857 }  ;
        //ignWmtsLayer.spatialReference = { wkid: 102100, latestWkid: 3857 }  ;

        //ignWmsLayer.spatialReferences[0] = 3857;
        console.log(ignWmsLayer.spatialReferences);
        console.log("spatialReference esriLayer  : " ,  esriLayer.spatialReference);
        console.log("spatialReference ignwms : " ,  ignWmsLayer.spatialReference);
        console.log("spatialReference ignWmtsLayer  : " , ignWmtsLayer.spatialReference);
      });

      var aLayers = [];

      // ESRI basemaps
      var strEsriUrl = "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer";
      esriLayer = new esri.layers.ArcGISTiledMapServiceLayer(strEsriUrl);

      // IGN basemaps 

      // WMS
      // https://wxs.ign.fr/cartes/geoportail/r/wms?request=GetCapabilities&amp;amp;service=WMS
      // Premier systeme de coordonnées de référence : CRS:84 comment le changer au chargement 
      var strIgnWmsUrl = "https://wxs.ign.fr/cartes/geoportail/r/wms";

      /*
      Test avec Layer info
      var WMSLayerInfo1 =  new esri.layers.WMSLayerInfo({
        name: 'SCANREG_PYR-JPEG_WLD_WM',
        title: 'SCANREG_PYR-JPEG_WLD_WM',
        spatialReferences : [3857]  
      });

      var resourcesInfo = {
          layerInfos: [WMSLayerInfo1],
          spatialReferences : [3857],
          extent: extent3857

      };

      ignWmsLayer = new esri.layers.WMSLayer(strIgnWmsUrl, {
            format: "jpeg",
            minScale: 100000000,
            maxScale: 200,
            resourceInfo : resourcesInfo,
            visibleLayers: ["SCANREG_PYR-JPEG_WLD_WM"],
            transparent: true,
            id: "WMS ScanRegion"
          });
      
      */

      ignWmsLayer = new esri.layers.WMSLayer(strIgnWmsUrl, {
              format: "jpeg",
              minScale: 100000000,
              maxScale: 200,
              visibleLayers: ["SCANREG_PYR-JPEG_WLD_WM"],
              transparent: true,
              id: "WMS ScanRegion"
      });

      // WMTS
      // https://wxs.ign.fr/ortho/geoportail/wmts?request=GetCapabilities&amp;amp;service=WMTS&amp;amp;version=1.0.0
      var strIgnWmtsUrl = "https://wxs.ign.fr/ortho/geoportail/wmts";
      
      var layerInfo =  new esri.layers.WMTSLayerInfo({
              identifier: "ORTHOIMAGERY.ORTHOPHOTOS",
              tileMatrixSet: "PM",
              format: "jpeg"
      });
      var ignOptions = {
              serviceMode: "KVP",
              minScale: 100000000,
              maxScale: 200,
              layerInfo: layerInfo
      };

      ignWmtsLayer = new esri.layers.WMTSLayer(strIgnWmtsUrl, ignOptions);

      // Add layers to array
      
      // esri first one =&amp;gt; OK it works
      /*aLayers.push(esriLayer);
      aLayers.push(ignWmtsLayer);
      aLayers.push(ignWmsLayer);*/

      // wmts first one =&amp;gt; OK it works
      /*aLayers.push(ignWmtsLayer);
      aLayers.push(ignWmsLayer);
      aLayers.push(esriLayer);*/

      // wms first one =&amp;gt; NO it doesn't work =&amp;gt; how change CRS WMS in spatialreferences ?
      aLayers.push(ignWmsLayer);
      aLayers.push(ignWmtsLayer);
      aLayers.push(esriLayer);

      // setVisibility first layer
      for (let index = 0; index &amp;lt; aLayers.length; index++) {
        let layer = aLayers[index];
        if (index == 0) layer.setVisibility(true);
        else layer.setVisibility(false);
      }
  
      // Add basemaps layers
      map.addLayers(aLayers);
    });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 18:02:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-display-with-wms-and-wmts/m-p/1212578#M78714</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2022-09-14T18:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: Problem display with WMS and WMTS</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-display-with-wms-and-wmts/m-p/1212878#M78722</link>
      <description>&lt;P&gt;OK thanks a lot ... it works &lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I suppose you guess you found the tile values ​​with the properties "level" on &lt;A href="https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" target="_blank"&gt;https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I can found the others values on wmts capabilities if I need&amp;nbsp; on element TileMatrixSet&lt;BR /&gt;sample : &lt;A href="https://wxs.ign.fr/ortho/geoportail/wmts?request=GetCapabilities&amp;amp;service=WMTS&amp;amp;version=1.0.0;" target="_blank"&gt;https://wxs.ign.fr/ortho/geoportail/wmts?request=GetCapabilities&amp;amp;service=WMTS&amp;amp;version=1.0.0;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;this is the reason why it work with wmts at first.&lt;/P&gt;&lt;P&gt;However, this solution is not automatic...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 13:00:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-display-with-wms-and-wmts/m-p/1212878#M78722</guid>
      <dc:creator>LionelGOUBET</dc:creator>
      <dc:date>2022-09-15T13:00:28Z</dc:date>
    </item>
  </channel>
</rss>

