I want to get my map setted to specific coordinates Xmin Xmax Ymin Ymax in javascript. Is it possible? How?

1047
2
12-27-2020 03:52 AM
SSRazvan
New Contributor
 
Tags (2)
2 Replies
RobertScheitlin__GISP
MVP Emeritus

If you are talking about the 4.x API then you use the view.goTo method.

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

Here is a sample that shows going to the extent of certain features in a layer:

https://developers.arcgis.com/javascript/latest/sample-code/sandbox/index.html?sample=featurelayer-q...

 

 

SethLutske
New Contributor III

If you are talking about having the map show specific coords based on xmin xmax ymin ymax when it first loads, you can use the `extent` property of the view:

const view = new MapView({
  map,
  extent: {
    xmin,
    xmax,
    ymin,
    ymax,
  }
})

The explanation for that is pretty early on in the MapView documentation .

If you're talking about getting the map to move to a certain extent some time after initialization, then the goTo method is what you need.