Hi,
I am looking for JavaScript API (js.arcgis.com/4.15) that enables to get the map visible area.
Hence, the X,Y coordinates of the visible area (polygon or rect coordiantes) of the presented map.
In android arcgis SDK there is method getVisibleArea() that does it
Google Map api provides it as:
var visibleRegion = googleMap.projection
visibleRegion.farRight.latitude, visibleRegion.farRight.longitude, visibleRegion.nearLeft.latitude, visibleRegion.nearLeft.longitude
I've made some expirimates retrieve it from
let view = new MapView({
container: "viewDiv",
map: map,
zoom: 7,
center: [-117.295800, 34.076295], // longitude, latitude, centered on Austria
constraints: {
minZoom: 16 // Use this constraint to avoid zooming out too far
}
});
view.when(function() {
let initialExtent = view.extent;
let height = initialExtent.height;
let mmax = initialExtent.mmax;
let mmin = initialExtent.mmin;
let type = initialExtent.type;
let width = initialExtent.width;
let xmax = initialExtent.xmax;
let xmin = initialExtent.xmin;
let ymax = initialExtent.ymax;
let ymin = initialExtent.ymin;
}However the numbers I get are not coordinates at all:
xmax: -13055474.239510546
xmin: -13059143.216868332
ymax: 4039950.5164796906
ymax: 4039950.5164796906
ymin: 4038151.857657808
Also, try to convert it to Polygon doesn't help:
var polygon = Polygon.fromExtent(initialExtent);
The polygon ring attribute contains the exact same values as above ... so it doesn't help at all.
I have no idea how they can be converted to the top right/left/top/bottom coordinates of the presented map. Maybe this is not the correct approach, however this is as far as I could get.
I've looked all over in MapView for getVisibleArea() and couldn't find,
Thanks.