<?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: Bug: MapImageLayer at International Dateline in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bug-mapimagelayer-at-international-dateline/m-p/1508295#M85084</link>
    <description>&lt;P&gt;For the very few people interested (if any at all), this occurs in 3.x as well.&amp;nbsp; The following hack to the _onExtentChangeHandler function of &lt;A href="https://developers.arcgis.com/javascript/3/jsapi/dynamicmapservicelayer-amd.html" target="_self"&gt;DynamicMapServiceLayer&lt;/A&gt; appears to do the job:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var _onExtentChangeHandler = DynamicMapServiceLayer.prototype._onExtentChangeHandler;

DynamicMapServiceLayer.prototype._onExtentChangeHandler = function(a, b, c) {
	if ((a) &amp;amp;&amp;amp; (a.declaredClass == "esri.geometry.Extent")) {
		var extents = a.normalize();

		if (extents.length == 2) {
			var ext1 = extents[0];
			var ext2 = new Extent(ext1.xmin, ext1.ymin, ext1.xmax + extents[1].getWidth(), ext1.ymax, ext1.spatialReference);
			ext2._normalize = function() { return this; };

			_onExtentChangeHandler.call(this, ext2, b, c);

			return;
		}
	}

	_onExtentChangeHandler.apply(this, arguments);
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Note, only tested with 3.46...&lt;/P&gt;</description>
    <pubDate>Mon, 22 Jul 2024 21:21:08 GMT</pubDate>
    <dc:creator>JoelBennett</dc:creator>
    <dc:date>2024-07-22T21:21:08Z</dc:date>
    <item>
      <title>Bug: MapImageLayer at International Dateline</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bug-mapimagelayer-at-international-dateline/m-p/1426668#M84539</link>
      <description>&lt;P&gt;We have a basic map service published to ArcGIS Server which displays some polygons.&amp;nbsp; Some of those polygons cross the International Dateline (ID), but they're getting clipped like shown:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="id1.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/103688i34A34C050C432EB9/image-size/large?v=v2&amp;amp;px=999" role="button" title="id1.png" alt="id1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;On the client, this is a basic &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html" target="_self"&gt;MapImageLayer&lt;/A&gt;.&amp;nbsp; I've noticed when the view crosses the ID, the SDK shifts the central meridian of the extent that gets sent to the export operation of the map service.&amp;nbsp; For the image above, the query parameters for the export operation are shown:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="id2.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/103689iA2F068F11E20DCBE/image-size/large?v=v2&amp;amp;px=999" role="button" title="id2.png" alt="id2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As can be seen, the bbox parameters are shifted from the extent of the View, and the Central_Meridian values of the spatial references are set to a value other than the default.&amp;nbsp; I don't really understand the inner workings of all that, but it nevertheless appears to be what's causing the problem.&lt;/P&gt;&lt;P&gt;I've come up with a hack to get this showing the expected images like so:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="id3.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/103690iF5DD551333C84AA4/image-size/large?v=v2&amp;amp;px=999" role="button" title="id3.png" alt="id3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is done by overriding the&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html#createExportImageParameters" target="_self"&gt;createExportImageParameters&lt;/A&gt; method of MapImageLayer.&amp;nbsp; I use &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#normalize" target="_self"&gt;Extent.normalize&lt;/A&gt; to determine if the image extent crosses the ID, and if it does, I expand the left piece by the width of the right piece, and use that for bbox instead:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var createExportImageParameters = MapImageLayer.prototype.createExportImageParameters;

MapImageLayer.prototype.createExportImageParameters = function(extent, width, height, options) {
	var exportImageParameters = createExportImageParameters.apply(this, arguments);

	if ((exportImageParameters.bbox) &amp;amp;&amp;amp; (this.spatialReference?.isWrappable)) {
		var extents = extent.normalize();

		if (extents.length == 2) {
			var ext1 = extents[0];

			exportImageParameters.bbox = ext1.xmin.toString() + "," + ext1.ymin.toString() + "," + (ext1.xmax + extents[1].width).toString() + "," + ext1.ymax.toString();
			exportImageParameters.bboxSR = JSON.stringify(extent.spatialReference.toJSON());
			exportImageParameters.imageSR = exportImageParameters.bboxSR;
		}
	}

	return exportImageParameters;
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Therefore, the query parameters for the proper image look like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="id4.png" style="width: 738px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/103691i6E5615B6A922164A/image-size/large?v=v2&amp;amp;px=999" role="button" title="id4.png" alt="id4.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems to be working fine, but could we get this fixed in the SDK itself?&amp;nbsp; Also, if there's a better temporary fix between now and then, I'd be grateful to know as well.&lt;/P&gt;&lt;P&gt;This occurred using version 4.29, but I don't know if it occurs in previous versions or not.&amp;nbsp; Also note, we observed the same behavior when loading the individual layers in as &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html" target="_self"&gt;FeatureLayers&lt;/A&gt;, but I didn't try tracking that one down.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2024 20:52:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bug-mapimagelayer-at-international-dateline/m-p/1426668#M84539</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2024-08-26T20:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: Bug: MapImageLayer at International Dateline</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bug-mapimagelayer-at-international-dateline/m-p/1508295#M85084</link>
      <description>&lt;P&gt;For the very few people interested (if any at all), this occurs in 3.x as well.&amp;nbsp; The following hack to the _onExtentChangeHandler function of &lt;A href="https://developers.arcgis.com/javascript/3/jsapi/dynamicmapservicelayer-amd.html" target="_self"&gt;DynamicMapServiceLayer&lt;/A&gt; appears to do the job:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var _onExtentChangeHandler = DynamicMapServiceLayer.prototype._onExtentChangeHandler;

DynamicMapServiceLayer.prototype._onExtentChangeHandler = function(a, b, c) {
	if ((a) &amp;amp;&amp;amp; (a.declaredClass == "esri.geometry.Extent")) {
		var extents = a.normalize();

		if (extents.length == 2) {
			var ext1 = extents[0];
			var ext2 = new Extent(ext1.xmin, ext1.ymin, ext1.xmax + extents[1].getWidth(), ext1.ymax, ext1.spatialReference);
			ext2._normalize = function() { return this; };

			_onExtentChangeHandler.call(this, ext2, b, c);

			return;
		}
	}

	_onExtentChangeHandler.apply(this, arguments);
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Note, only tested with 3.46...&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2024 21:21:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bug-mapimagelayer-at-international-dateline/m-p/1508295#M85084</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2024-07-22T21:21:08Z</dc:date>
    </item>
  </channel>
</rss>

