I am having trouble in finding map extent (bounding box). How can I easily find out the extent and its format ?
Suppose I have this code sample:
const view = new MapView({
container: "viewDiv",
map: map,
extent: {
// autocasts as new Extent()
xmin: -9177811,
ymin: 4247000,
xmax: -9176791,
ymax: 4247784,
spatialReference: 102100
I want to direct the extent (xmin/max, ymin/max) to a particular city with spatial reference 102100. How to do that ?
And also, spatialReference 102100 (line 11) is deprecated and changed to EPSG 3857. (https://spatialreference.org/ref/esri/102100/) . Do I have to change the "spatialReference: 102100" to "spatialReference: 3857" ?
Thanks
You can add a `console.log` to output the view.extent.
If you add it inside a reactiveUtils.watch you can get it to output to the browser console as you move around the map to the city / extent that you want.
reactiveUtils.watch(
() => view.updating,
(updating) => {
console.log('extent', view.extent)
});
If you want the map itself to goto an extent, then you can use `goTo` and pass in a geometry that matches your extent (or use Polygon.fromExtent to convert it)
https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#fromExtent
https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo