Thank you @kerenc for your assistance.
Code fails during runtime:
projection.load()
esri.html?_ijt=b7g5ecd5goqr8hnarkbpa2atn5:66 Uncaught (in promise) TypeError: projection.getTransformations(...).then is not a function
at esri.html?_ijt=b7g5ecd5goqr8hnarkbpa2atn5:66
Can you please advise how to fix?
Also, I am not fixed with specific method for getting map projection. Also tried GeometryService that failed since require("esri/tasks/GeometryService") gives Error: undefinedModule ... however here is the code:
require([
"esri/Map",
"esri/views/MapView",
"esri/geometry/projection",
"esri/geometry/SpatialReference"
], function (Map, MapView, Projection, SpatialReference) {
let map = new Map({
basemap: "streets"
});
let view = new MapView({
container: "viewDiv",
map: map,
zoom: 7,
center: [-117.2958, 34.076295], // longitude, latitude, centered on Austria
constraints: {
minZoom: 16 // Use this constraint to avoid zooming out too far
}
});
view.watch('extent',getProjection)
function getProjection(camera) {
if(camera.extent.xmin == undefined)
return;
const initialExtent = view.extent;
const Point = require("esri/geometry/Point");
const GeometryService = require("esri/tasks/GeometryService");
const ProjectParameters = require("esri/tasks/support/ProjectParameters");
var pointTopRight = new Point(initialExtent.xmin, initialExtent.ymin, map.spatialReference );
var pointBottomLeft = new Point(initialExtent.xmax, initialExtent.ymax, map.spatialReference );
var gsvc = new GeometryService("https://utility.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
var params = new ProjectParameters();
params.geometries = [pointTopRight, pointBottomLeft];
params.outSR = map.spatialReference;
gsvc.project(params, function(results){
console.log(results)
});
}
});
(index):32 Uncaught Error: undefinedModule
at n ((index):32)
at Z ((index):39)
at d ((index):32)
at getProjection (esri.html?_ijt=b7g5ecd5goqr8hnarkbpa2atn5:59)
@kerenc As you could see I've tried to solve the problem from different angels, so far no success.
I thought that the question of getting the boudries coordinates (Lat, Lon) of a map view should be fundamental. I hoped to find a straightforward way to get it.
Thanks for your kind help, any solution that can provide the mapView Lon/Lat visible area projection is most Wellcome. Looking forward your respone.
Best,
Gabriel