<?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 Custom DynamicLayer in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-dynamiclayer/m-p/1412276#M84379</link>
    <description>&lt;P&gt;Can this method also be used to customize things like MapImageLayer to read MapServer?&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt; const CustomWMSLayer = BaseDynamicLayer.createSubclass({
          properties: {
            mapUrl: null,
            mapParameters: null
          },

          // Override the getImageUrl() method to generate URL
          // to an image for a given extent, width, and height.
          getImageUrl: function (extent, width, height){
            const urlVariables = this._prepareQuery(this.mapParameters, extent, width, height);
            const queryString = this._joinUrlVariables(urlVariables);
            return this.mapUrl + "?" + queryString;
          },

          // Prepare query parameters for the URL to an image to be generated
          _prepareQuery: function (queryParameters, extent, width, height) {
            const wkid = extent.spatialReference.isWebMercator ? 3857 : extent.spatialReference.wkid;
            const replacers = {
              width: width,
              height: height,
              wkid: wkid,
              xmin: extent.xmin,
              xmax: extent.xmax,
              ymin: extent.ymin,
              ymax: extent.ymax
            };

            const urlVariables = this._replace({}, queryParameters, replacers);
            return urlVariables;
          },

          // replace the url variables with the application provided values
          _replace: (urlVariables, queryParameters, replacers) =&amp;gt; {
            Object.keys(queryParameters).forEach((key) =&amp;gt; {
              urlVariables[key] = Object.keys(replacers).reduce((previous, replacerKey) =&amp;gt; {
                return previous.replace("{" + replacerKey + "}", replacers[replacerKey]);
              }, queryParameters[key]);
            });

            return urlVariables;
          },

          // join the url parameters
          _joinUrlVariables: (urlVariables) =&amp;gt; {
            return Object.keys(urlVariables).reduce((previous, key) =&amp;gt; {
              return previous + (previous ? "&amp;amp;" : "") + key + "=" + urlVariables[key];
            }, "");
          }
        });&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 19 Apr 2024 14:21:54 GMT</pubDate>
    <dc:creator>Wade</dc:creator>
    <dc:date>2024-04-19T14:21:54Z</dc:date>
    <item>
      <title>Custom DynamicLayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-dynamiclayer/m-p/1412276#M84379</link>
      <description>&lt;P&gt;Can this method also be used to customize things like MapImageLayer to read MapServer?&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt; const CustomWMSLayer = BaseDynamicLayer.createSubclass({
          properties: {
            mapUrl: null,
            mapParameters: null
          },

          // Override the getImageUrl() method to generate URL
          // to an image for a given extent, width, and height.
          getImageUrl: function (extent, width, height){
            const urlVariables = this._prepareQuery(this.mapParameters, extent, width, height);
            const queryString = this._joinUrlVariables(urlVariables);
            return this.mapUrl + "?" + queryString;
          },

          // Prepare query parameters for the URL to an image to be generated
          _prepareQuery: function (queryParameters, extent, width, height) {
            const wkid = extent.spatialReference.isWebMercator ? 3857 : extent.spatialReference.wkid;
            const replacers = {
              width: width,
              height: height,
              wkid: wkid,
              xmin: extent.xmin,
              xmax: extent.xmax,
              ymin: extent.ymin,
              ymax: extent.ymax
            };

            const urlVariables = this._replace({}, queryParameters, replacers);
            return urlVariables;
          },

          // replace the url variables with the application provided values
          _replace: (urlVariables, queryParameters, replacers) =&amp;gt; {
            Object.keys(queryParameters).forEach((key) =&amp;gt; {
              urlVariables[key] = Object.keys(replacers).reduce((previous, replacerKey) =&amp;gt; {
                return previous.replace("{" + replacerKey + "}", replacers[replacerKey]);
              }, queryParameters[key]);
            });

            return urlVariables;
          },

          // join the url parameters
          _joinUrlVariables: (urlVariables) =&amp;gt; {
            return Object.keys(urlVariables).reduce((previous, key) =&amp;gt; {
              return previous + (previous ? "&amp;amp;" : "") + key + "=" + urlVariables[key];
            }, "");
          }
        });&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 19 Apr 2024 14:21:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-dynamiclayer/m-p/1412276#M84379</guid>
      <dc:creator>Wade</dc:creator>
      <dc:date>2024-04-19T14:21:54Z</dc:date>
    </item>
  </channel>
</rss>

