arcgisapi4.x3857转4326
arcgisapi4.x3857转4326
“esri/geometry/support/webMercatorUtils”,引入方法
参考官网连接https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-webMercatorUtils.html#xyToLngLat
使用如下:
//监听坐标变化
var handle = view.watch("camera.position", function (newValue, oldValue, propertyName, object) {
// console.log(propertyName + " 从一个视角 " + oldValue + " 变成 " + newValue);
console.log("新坐标x:" + newValue.x + " 新坐标y: " + newValue.y + " 新坐标z: " + newValue.z);
//摩卡托转经纬度
let lonlat = webMercatorUtils.xyToLngLat(newValue.x, newValue.y);
console.log(lonlat, "经纬度");
});
视角监听
哈哈哈,,之前发过一个监听视角的,那个应该是实时的坐标,这个坐标好像没取对。仅供参考。
//监听fov
var handle3 = view.watch("camera.fov", function (newValue, oldValue, propertyName, object) {
console.log(propertyName + " 从一个fov " + oldValue + " 变成 " + newValue);
});
// //监听heading
var handle1 = view.watch("camera.heading", function (newValue, oldValue, propertyName, object) {
console.log(propertyName + " 从一个heading " + oldValue + " 变成 " + newValue);
});
// //监听tilt
var handle2 = view.watch("camera.tilt", function (newValue, oldValue, propertyName, object) {
console.log(propertyName + " 从一个tilt " + oldValue + " 变成 " + newValue);
});