<?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: esriRequest WebTiledLayer Cannot read property 'indexOf' of null in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esrirequest-webtiledlayer-cannot-read-property/m-p/1011499#M71155</link>
    <description>&lt;P&gt;Short term goal accomplished. The issue was "this" and the scope. I used lang.hitch as suggested in &lt;A title="Accessing Map from Widget code" href="https://community.esri.com/t5/arcgis-web-appbuilder-questions/accessing-map-from-widget-code/m-p/677191" target="_self"&gt;Accessing Map from Widget code&lt;/A&gt;. Thanks Robert - the help was not for my question post but out there nonetheless and very much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;    startup: function() {
      this.inherited(arguments);
      var corsEnabledServers = esriConfig.defaults.io.corsEnabledServers;
      corsEnabledServers.push("tiles.clearapis.com");
      
      var requestHandle = esriRequest({
            url: "https://tiles.clearapis.com/v1.0/layer_index?app_id=XX&amp;amp;app_key=XX",
            handleAs : "json",
      });

      requestHandle.then(lang.hitch(this, requestSucceeded), requestFailed);
      
      function requestSucceeded(result, io){
        let tileRadar = result.display_intervals[0].layers.contigus.radar.tile_url;
        const urlUSRadar = `${tileRadar}{level}/{col}/{row}.png?app_id=XX&amp;amp;app_key=XX`;

        var radar = new WebTiledLayer(urlUSRadar);
        this.map.addLayer(radar);         
      }

      function requestFailed(error, io) {
        alert(dojoJson.toJson(error, true));
      }

    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Dec 2020 21:09:10 GMT</pubDate>
    <dc:creator>windmilling</dc:creator>
    <dc:date>2020-12-29T21:09:10Z</dc:date>
    <item>
      <title>esriRequest WebTiledLayer Cannot read property 'indexOf' of null</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esrirequest-webtiledlayer-cannot-read-property/m-p/1011345#M71148</link>
      <description>&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN&gt;I am so grateful for this Community; the searching here has been a tremendous help to this person learning as he slowly progresses along on a project. Currently I am learning about esriRequest in developer WebAppBuilderForArcGIS/client/stemapp/widgets/samplewidgets in the startup: function(){ so js.arcgis.com/3.34. With the commented code, the cosole.log produces the url I expect with the getContent(); line. I know my radar lines have no ties to the esriRequest lines, but I can paste the url from the console.log into the new WebTiledLayer and add the layer with this.map.addLayer(radar); (in other words, I know the request works and the add layer works). I know my old commented chunk is incomplete, so I did more searching and found&lt;/SPAN&gt;&lt;A href="https://community.esri.com/t5/arcgis-api-for-javascript/json-into-arcgis-javascript-webapp/m-p/186602" target="_blank" rel="noopener"&gt; &lt;SPAN&gt;Subject Json into ArcGIS Javascript webapp 5/23-24/2015&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;. I tried to apply the Graphics from that question to the WebTiles in my situation (code below). My first try, I had var wtl = new WebTiledLayer(); and I got an error with respect to substring. I changed the line to var wtl = new WebTiledLayer(""); and now the error is Cannot read property 'indexOf' of null. The term for this thing I am messing up is "instantiation"? I imagine I am missing a number of these and/or I am also messing up other things? indexOf is associated with ?? map? WebTiledLayer? an array? Earlier I had trouble with the corsEnabledServers.push line as well, but with searching found that the previous line was needed before the push. PS. Getting this to work is a learning step for something else. In other words, the short term goal is change map with add layer with widget startup, but it is not the long term goal.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    startup: function() {
      this.inherited(arguments);
      var corsEnabledServers = esriConfig.defaults.io.corsEnabledServers;
      corsEnabledServers.push("tiles.clearapis.com");

      var wtl = new WebTiledLayer("");
      this.map.addLayer(wtl);
      
      var locsRequest = esriRequest({
        url: "https://tiles.clearapis.com/v1.0/layer_index?app_id=XX&amp;amp;app_key=XX",
        handleAs: "json"
      });

      var radar;

      locsRequest.then(
        function(response) {
          var tileRadar = response.display_intervals[0].layers.contigus.radar.tile_url;
          var urlUSRadar = `${tileRadar}/{level}/{col}/{row}.png?app_id=XX&amp;amp;app_key=XX`;
          radar = new WebTiledLayer(urlUSRadar);
            wtl.add(radar);
        }, 
        function(error) {console.log("Error: ", error.message);
        });
    
      // function getContent(){
      //   var req = esriRequest({
      //       url: "https://tiles.clearapis.com/v1.0/layer_index?app_id=XX&amp;amp;app_key=XX",
      //       handleAs : "json",
      //   });
      //   req.then(Succeeded);
      // }
      // function Succeeded(result){
      //   let tileRadar = result.display_intervals[0].layers.contigus.radar.tile_url;
      //   const urlUSRadar = `${tileRadar}/{level}/{col}/{row}.png?app_id=XX&amp;amp;app_key=XX`;
        
      //   console.log(urlUSRadar);
      // }
      
      // getContent();

      // var radar = new WebTiledLayer("http://ag.us.clearapis.com/v1.0/gmaps/radar/1608470400/47415230/{level}/{col}/{row}.png?app_id=XX&amp;amp;app_key=XX");
      // this.map.addLayer(radar);
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;edit It turns out I was not on the right track with neither the original reply nor the question, so I moved the following from the original reply to here at the end of the initial post....... I noticed an inconsistency with what I did and the case I used as a template. The correct graphic = new Graphic from the post-solution I was working off of is not an equivalent to my incorrect radar = new WebTiledLayer. I am thinking this is only part of my problem? endedit&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2020 21:16:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esrirequest-webtiledlayer-cannot-read-property/m-p/1011345#M71148</guid>
      <dc:creator>windmilling</dc:creator>
      <dc:date>2020-12-29T21:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: esriRequest WebTiledLayer Cannot read property 'indexOf' of null</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esrirequest-webtiledlayer-cannot-read-property/m-p/1011499#M71155</link>
      <description>&lt;P&gt;Short term goal accomplished. The issue was "this" and the scope. I used lang.hitch as suggested in &lt;A title="Accessing Map from Widget code" href="https://community.esri.com/t5/arcgis-web-appbuilder-questions/accessing-map-from-widget-code/m-p/677191" target="_self"&gt;Accessing Map from Widget code&lt;/A&gt;. Thanks Robert - the help was not for my question post but out there nonetheless and very much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;    startup: function() {
      this.inherited(arguments);
      var corsEnabledServers = esriConfig.defaults.io.corsEnabledServers;
      corsEnabledServers.push("tiles.clearapis.com");
      
      var requestHandle = esriRequest({
            url: "https://tiles.clearapis.com/v1.0/layer_index?app_id=XX&amp;amp;app_key=XX",
            handleAs : "json",
      });

      requestHandle.then(lang.hitch(this, requestSucceeded), requestFailed);
      
      function requestSucceeded(result, io){
        let tileRadar = result.display_intervals[0].layers.contigus.radar.tile_url;
        const urlUSRadar = `${tileRadar}{level}/{col}/{row}.png?app_id=XX&amp;amp;app_key=XX`;

        var radar = new WebTiledLayer(urlUSRadar);
        this.map.addLayer(radar);         
      }

      function requestFailed(error, io) {
        alert(dojoJson.toJson(error, true));
      }

    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2020 21:09:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esrirequest-webtiledlayer-cannot-read-property/m-p/1011499#M71155</guid>
      <dc:creator>windmilling</dc:creator>
      <dc:date>2020-12-29T21:09:10Z</dc:date>
    </item>
  </channel>
</rss>

