Bug: MapImageLayer at International Dateline

107
0
2 weeks ago
JoelBennett
MVP Regular Contributor

We have a basic map service published to ArcGIS Server which displays some polygons.  Some of those polygons cross the International Dateline (ID), but they're getting clipped like shown:

id1.png

On the client, this is a basic MapImageLayer.  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.  For the image above, the query parameters for the export operation are shown:

 id2.png

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.  I don't really understand the inner workings of all that, but it nevertheless appears to be what's causing the problem.

I've come up with a hack to get this showing the expected images like so:

id3.png

This is done by overriding the createExportImageParameters method of MapImageLayer.  I use Extent.normalize 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:

var createExportImageParameters = MapImageLayer.prototype.createExportImageParameters;

MapImageLayer.prototype.createExportImageParameters = function(extent, width, height, options) {
	var exportImageParameters = createExportImageParameters.apply(this, arguments);

	if (exportImageParameters.bbox) {
		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;
};

 

Therefore, the query parameters for the proper image look like this:

id4.png

 

It seems to be working fine, but could we get this fixed in the SDK itself?  Also, if there's a better temporary fix between now and then, I'd be grateful to know as well.

This occurred using version 4.29, but I don't know if it occurs in previous versions or not.  Also note, we observed the same behavior when loading the individual layers in as FeatureLayers, but I didn't try tracking that one down.

0 Kudos
0 Replies