Hi all,
I am using worldelevation3D service to display X-Y-Z coordinates, but X and Y i want to show in WKID: 32638,
let beforeLandslideUrl =
"https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer";
const sr1 = new SpatialReference({ wkid: 32638 });
let beforeLandslideLayer = new ElevationLayer({
url: beforeLandslideUrl,
spatialReference: sr1
});
view.on("click", function(event) {
var xyztext = document.getElementById("xyzcheckbox");
if(xyztext.checked == true){
// Query both elevation layers for the elevation at the clicked map position
var position = event.mapPoint;
var queryBeforeLandslide = beforeLandslideLayer.queryElevation(position);
// When both query promises resolve execute the following code
promiseUtils
.eachAlways([queryBeforeLandslide])
.then(function(results) {
var posBeforeLandslide = results[0].value.geometry;
// Clear graphics from previous result (if applicable)
//view.graphics.removeAll();
//alert("ზღვის დონიდან: " + posBeforeLandslide.z +", " + "x: " + posBeforeLandslide.x + ", " + "y: " + posBeforeLandslide.y)
// document.getElementById('xyzspan').innerHTML = "X: " + posBeforeLandslide.x.toFixed(2)+ "; " + "Y: " + posBeforeLandslide.y.toFixed(2)+ "; " + "Z: " + posBeforeLandslide.z.toFixed(2);
document.getElementById('xspan').innerHTML = "X: " + posBeforeLandslide.x.toFixed(2);
document.getElementById('yspan').innerHTML = "Y: " + posBeforeLandslide.y.toFixed(2);
document.getElementById('zspan').innerHTML = "Z: " + posBeforeLandslide.z.toFixed(2);
})
}
else
{
//view.graphics.removeAll();
}
});
Solved! Go to Solution.
https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-projection.html#project
You will need to call project somewhere in your code. It will be easier and probably perform better to re-project the mouse click, but if you want the map to actually display in WKID: 32638 you will need to do a forEach loop like the first example to re-project all of the graphics.
https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-projection.html#project
You will need to call project somewhere in your code. It will be easier and probably perform better to re-project the mouse click, but if you want the map to actually display in WKID: 32638 you will need to do a forEach loop like the first example to re-project all of the graphics.
Thanks Jeffry, you gave me right direction, i simply change projection of clicked point and it works fine. Thanks
Working code:
var beforeLandslideUrl =
"https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer";
var beforeLandslideLayer = new ElevationLayer({
url: beforeLandslideUrl
});
view.on("click", function(event) {
var xyztext = document.getElementById("xyzcheckbox");
if(xyztext.checked == true){
// Query both elevation layers for the elevation at the clicked map position
let sr1 = new SpatialReference({ wkid: 32638 });
var position = event.mapPoint;
let projectedPoints = projection.project(position, sr1);
console.log(projectedPoints);
var queryBeforeLandslide = beforeLandslideLayer.queryElevation(position);
// When both query promises resolve execute the following code
promiseUtils
.eachAlways([queryBeforeLandslide])
.then(function(results) {
var posBeforeLandslide = results[0].value.geometry;
document.getElementById('xspan').innerHTML = "X: " + posBeforeLandslide.x.toFixed(2);
document.getElementById('yspan').innerHTML = "Y: " + posBeforeLandslide.y.toFixed(2);
document.getElementById('zspan').innerHTML = "Z: " + posBeforeLandslide.z.toFixed(2);
})
}
else
{
//view.graphics.removeAll();
}
});