Extent crossing international dateline

I’m trying to draw a polygon that crosses the International Dateline. I am using an ExtentPrimitive to do this. However, this fails; I get an “Invalid arguments” on this line in ExtentGeometry.cs (line number 344 in b22):

     var positions = (vertexFormat.position) ? new Float64Array(size * 3) : undefined;

It turns out, size is negative. Size is calculated here (line number 779 in b22):

      var size = width * height;

And width comes from (line number 715 in b22):

       var width = Math.ceil((extent.east - extent.west) / granularity) + 1;

Which I think is where the problem is. Since my box cross the IDL, my east value is negative and my west value is positive, thus giving me a negative width, which leads to a negative size, causing the above error. If I reverse east and west, the image will draw, but it’s wrapping around the wrong side of the globe (basically, going in the wrong direction). Given that Extent requires east and west to be between -PI and +PI, I don’t really see other options. I’m hoping the fix is as simple as an absolute value on the above line of code. Or is there something I can do on my end to make this work?



Currently, the ExtentGeometry cannot cross the IDL. It is set up so that west cannot be greater than east to avoid confusion about which way the extent should wrap around the globe. (I actually just noticed that the statement that’s supposed to check for this condition was missing, I just opened a pull request to re-add that DeveloperError). In order to get around this, you would need to change the implementation of ExtentGeometry.

The Polygon primitive, however, can cross the IDL. You may be able to use that instead.


Hi. Thanks for your
quick response! The reason I was using ExtentGeometry is because I was getting
a lot of distortion when using a normal polygon. ExtentGeometry (albeit in the
opposite direction) did not produce this distortion. This is how I was setting
up my polygon:


this._view.ellipsoid.cartographicToCartesian(new Cartographic(points[2],
points[3], 0)),


Cartographic(points[0], points[3], 0)),

this._view.ellipsoid.cartographicToCartesian(new Cartographic(points[2],
points[1], 0)),


Cartographic(points[0], points[1], 0))


The four points are the NE, NW, SE, and SW corners of the rectangle I want to draw. However, the image is being overly stretched on the surface of the globe… when I include lat/lon grid lines in my image, I can see them overarching from the distortion. ExtentPrimitive did not do this. Can you point me in the right direction here?

Thanks again!

Hmm. I’m guessing this is because the extent follows the lat/lon lines, where the sides of a polygon will take the shortest path between the points. When the size of the extent/polygon is small, the difference isn’t noticeable. It sounds like this might not work for your case though.


Hannah is right about the difference between extent and polygon edges. You could also explicitly use two extent geometries when an extent cross the IDL.


Let me just ask one more question. I am somewhat new at this and just want to make sure I’m not overlooking something obvious. In a nutshell, I want to put a large image on the globe… something that covers roughly 140 x 140 degrees. Note: this is not a layer, I want a shape with a defined image that is not part of the base map/layer. With normal polygons, the image is being stretched and distorted. Is there another shape object, or an option to polygon that would correct this (other than Extent)?

Thanks for all your help!

We generally use imagery layers to put images on the globe (tutorial). If an ExtentPrimitive + image material meets your needs, an imagery layer should too. If you need to use a polygon + image material to get a custom shape, and do not like the the way the image is mapped (it is mapped to the largest bounding rectangle around the polygon), you can use the textureRotationAngle property to rotate the image or the repeat property on the material to tile it. For a more custom mapping, make a new material (tutorial).