Convert extent width & height to zoom

283
2
02-02-2021 07:03 AM
KhaledTaymour
New Contributor

Hello, is there a function in the JS API that convert a certain extent object to the lat, lng, zoom,
I found the center which contains the lat & lng,
I am searching for somehow convert the "width" & "height" to "zoom" value.

Kind Regards

Khaled

Tags (3)
0 Kudos
2 Replies
JeffK
by MVP Regular Contributor
MVP Regular Contributor

When you say object extent, what are you referring to exactly?  Found this codepen Watching map view extents where you can add an output for view.zoom, change the initial extent to your values and then maybe get the zoom.  ... But the Zoom levels (LOD) are predetermined by the map service, so that could be interesting.

 

 

 

0 Kudos
BlakeTerhune
MVP Regular Contributor

Is this so you can zoom the map to a particular extent? If so, MapView.goTo() works with the Extent object.

Zoom to extent of all features | ArcGIS API for JavaScript

0 Kudos