Select to view content in your preferred language

How do I pass the clipping parameter for the export request in ArcGIS API for JavaScript 3

439
3
Jump to solution
12-15-2022 11:19 AM
YohanBienvenue
Frequent Contributor

Starting at ArcGIS Server 10.8, for map services using the ArcGIS Pro runtime, the export request now supports the clipping parameter to clip the image produced, according to the geometry included in the clipping parameter.

This works fine when I test it manually (e.g. Either through the ArcGIS REST Services Directory for the export request, or by using Postman). The image is clipped. However I need to do this clipping within a web application using the ArcGIS API for Javascript 3.

For instance for the ArcGISDynamicMapServiceLayer I see no obvious way to input this clipping parameter. Neither directly or through some other configuration. Is this possible?

If this is not currently supported in the ArcGIS API for Javascript 3, is there a way to hack in some extra parameters when the API makes export requests? So that I could manually set this clipping myself?

0 Kudos
1 Solution

Accepted Solutions
JoelBennett
MVP Regular Contributor

In terms of hacks, I think esriRequest.setRequestPreCallback may be your best bet.  It allows you to intercept and modify requests before they're sent.  I think it's there that you could add the clipping parameter and value.

View solution in original post

3 Replies
JoelBennett
MVP Regular Contributor

In terms of hacks, I think esriRequest.setRequestPreCallback may be your best bet.  It allows you to intercept and modify requests before they're sent.  I think it's there that you could add the clipping parameter and value.

YohanBienvenue
Frequent Contributor

I guess that could work if I did the request manually myself whenever the map was panned or zoomed, but I'd prefer letting the API do the export request itself.

I did some experimenting and found that I could hack in some extra parameters by adding them to the private _params property of the layer.

Ex:
 
const layer = new ArcGISDynamicMapServiceLayer(url, options)
layer._params.clipping = JSON.stringify({
     geometryType: 'esriGeometryPolygon',
     geometry: {
     rings: [[[382057.1446,5390601.6059],[382057.2633,5390601.4493],[382057.3779,5390601.2897],[382057.4883,5390601.1272],[382057.5946,5390600.9619],[382057.6965,5390600.7939],[382057.7941,5390600.6234],[382057.8872,5390600.4504],[382057.9758,5390600.275],[382058.0599,5390600.0974],[382058.1394,5390599.9177],[382058.2142,5390599.736],[382058.2844,5390599.5525],[382058.3497,5390599.3672],[382058.4103,5390599.1803],[382058.466,5390598.9919],[382058.5169,5390598.8021],[382058.5628,5390598.611],[382058.6038,5390598.4189],[382058.6398,5390598.2257],[382058.6708,5390598.0317],[382058.6969,5390597.8369],[382058.7178,5390597.6416],[382058.7338,5390597.4457],[382058.7447,5390597.2495],[382058.7505,5390597.0531],[382058.7513,5390596.8566]]],
     spatialReference: { wkid: 32188, latestWkid: 32188 }
     }
})
 
It works, the image is clipped properly.
Thanks
0 Kudos
YohanBienvenue
Frequent Contributor

Actually Joel, you were right. It does appear that esriRequest.setRequestPreCallback is called for each and every export request automatically. That's very nice, and will simplify a lot of things for me.

Thanks!

0 Kudos