<?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 Skip adding a layer if the Map Service is down? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/skip-adding-a-layer-if-the-map-service-is-down/m-p/724#M47</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've got a web map that consumes a number of map services.&amp;nbsp; Most are hosted on our internal server, but a couple are hosted externally.&amp;nbsp; One particular service tends to go down somewhat regularly, and when this happens the map itself breaks (not entirely, but it loses enough functionality to be a problem).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Outside of manually checking the web map every morning, I have absolutely no idea how to deal with this.&amp;nbsp; What usually happens is the service goes down in the middle of the day, we have a complaint from a customer, and I have to manually update the code to skip adding that service to the map until I get word that the service is back up.&amp;nbsp; Is there a better way of handling this?&amp;nbsp; Some way to use JS to check to see if the service is up and running before attempting to add the service?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Mar 2016 19:30:52 GMT</pubDate>
    <dc:creator>BrettGreenfield__DNR_</dc:creator>
    <dc:date>2016-03-08T19:30:52Z</dc:date>
    <item>
      <title>Skip adding a layer if the Map Service is down?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/skip-adding-a-layer-if-the-map-service-is-down/m-p/724#M47</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've got a web map that consumes a number of map services.&amp;nbsp; Most are hosted on our internal server, but a couple are hosted externally.&amp;nbsp; One particular service tends to go down somewhat regularly, and when this happens the map itself breaks (not entirely, but it loses enough functionality to be a problem).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Outside of manually checking the web map every morning, I have absolutely no idea how to deal with this.&amp;nbsp; What usually happens is the service goes down in the middle of the day, we have a complaint from a customer, and I have to manually update the code to skip adding that service to the map until I get word that the service is back up.&amp;nbsp; Is there a better way of handling this?&amp;nbsp; Some way to use JS to check to see if the service is up and running before attempting to add the service?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Mar 2016 19:30:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/skip-adding-a-layer-if-the-map-service-is-down/m-p/724#M47</guid>
      <dc:creator>BrettGreenfield__DNR_</dc:creator>
      <dc:date>2016-03-08T19:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: Skip adding a layer if the Map Service is down?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/skip-adding-a-layer-if-the-map-service-is-down/m-p/725#M48</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P class=""&gt;Brett,&lt;/P&gt;&lt;P class=""&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp; Sure you would use esriRequest to get the json of the map service url and if that esriRequest fails then you do not add that service layer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Mar 2016 19:36:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/skip-adding-a-layer-if-the-map-service-is-down/m-p/725#M48</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2016-03-08T19:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Skip adding a layer if the Map Service is down?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/skip-adding-a-layer-if-the-map-service-is-down/m-p/726#M49</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;script src="//cdn.polyfill.io/v2/polyfill.min.js?features=default,Promise"&amp;gt;&amp;lt;/script&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var sampleUrl = "//services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer";
var badUrl = "//services.arcgisonline.com/ArcGIS/rest/services/Reference/FakeService/MapServer"

/**
 * Tests a URL
 * @param {string} url
 * @returns {Promise}
 */
function testService(url) {
&amp;nbsp; return new Promise(function(resolve, reject) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var request = new XMLHttpRequest();
&amp;nbsp;&amp;nbsp;&amp;nbsp; request.open("get", url + "?f=json");
&amp;nbsp;&amp;nbsp;&amp;nbsp; request.onloadend = function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (this.status !== 200) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; reject({error: this.status});
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var response = JSON.parse(this.response);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (response.error) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; reject(response);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; resolve(response);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; request.send();
&amp;nbsp; });
}

[sampleUrl, badUrl].forEach(function(url) {
&amp;nbsp; testService(url).then(function(response) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; console.debug(response)
&amp;nbsp; }, function(error){
&amp;nbsp;&amp;nbsp;&amp;nbsp; console.error(error);
&amp;nbsp; });
});
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:02:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/skip-adding-a-layer-if-the-map-service-is-down/m-p/726#M49</guid>
      <dc:creator>JeffJacobson</dc:creator>
      <dc:date>2021-12-10T20:02:51Z</dc:date>
    </item>
  </channel>
</rss>

