Select to view content in your preferred language

Failing to set MapView.extent exactly...

550
1
Jump to solution
10-25-2022 02:27 PM
TonyGraham
Occasional Contributor

I'm trying to dynamically update the extent of a 500px x 400px map such that the view contains all of Corsica and Sardinia (an artificial example).  (See codepen https://codepen.io/tonygraham/pen/eYKYLqX).  

However, the resulting view clips the region that I expected to see, and neither Corsica nor Sardinia "fits".

Am I missing some subtlety with scale or zoom?  Should I be setting those as well?

My real use case is that I have some projected data already graphed that I want to display above the map at an exact extent, but I think I'm lacking the control I need over the extent to do it.

1 Solution

Accepted Solutions
BjornSvensson
Esri Regular Contributor

@TonyGraham - By default the MapView will snap to the LODs. You can turn that off, and it should zoom to the exact extent you set.

constraints: {
  snapToZoom: false
}

https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#constraints 

View solution in original post

1 Reply
BjornSvensson
Esri Regular Contributor

@TonyGraham - By default the MapView will snap to the LODs. You can turn that off, and it should zoom to the exact extent you set.

constraints: {
  snapToZoom: false
}

https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#constraints