JavaScript ArcGIS: Update scene clipping area after creation

08-10-2022 05:14 AM
New Contributor

I want to update (increase / decrease) scene clipping area after I create it. My goal is to give the user ability to adjust the clipping area. I am using scene view, if that's relevent.

I've managed to update the clipping area of the map using:

const extent = view.clippingArea.clone();
view.clippingArea = extent.expand(0.5);

However when I try to set it to a specific range it does not want work:

let extent = view.clippingArea.clone();
extent.extent.xmax = 1849093
extent.extent.xmin = 1488933
extent.extent.ymax = 5921967
extent.extent.ymin = 5688179

view.clippingArea = extent

How can I set clipping area to specific range.

0 Kudos
1 Reply
Esri Contributor

Hi @Serbian!

Looks like you use one level of  `extents` too many in your code. Try instead: 


let extent = view.clippingArea.clone();
extent.xmax = 1849093;
extent.xmin = 1488933;
extent.ymax = 5921967;
extent.ymin = 5688179;

view.clippingArea = extent;


Alternatively, you can also substitute the whole clippingArea with a new Extent at once (without cloning): 


view.clippingArea = {
  // autocasts as new Extent()
  xmax: 1849093,
  xmin: 1488933,
  ymax: 5921967,
  ymin: 5688179,
  spatialReference: {
    // autocasts as new SpatialReference()
    wkid: 3857 // Make sure this is the wkid of the spatial reference your view uses!


Here's a sample app which switches between 3 different clipping extents: 

0 Kudos