Edit: I am open to any solution -- simple is better, GeometryService/Engine whatever works.
Back again, lots of interesting requirements lately!
This time I'm attempting to get the x/y values of point geometry in 102100/3857 as planar coordinates (wkid 2881). Is there a simplified projectAs() function in the ESRI Javascript 3.x?
I've been attempting to implement projection but not having success with the overcoming errors with the geoTransformation.
layer.layerObject.queryFeatures(query, function (f) {
const inSpatialReference = new SpatialReference({ wkid: 102100 });
const spSpatialReference = new SpatialReference({ wkid: 2881 });
var geoT = projection.getTransformations(inSpatialReference, spSpatialReference)
for (var i in f['features']) {
var facObj = Object.assign({}, f.features[i]['attributes']);
const point = new Point(f.features[i].geometry, inSpatialReference);
const projectedPoint = projection.project(point, spSpatialReference, geoT);
facObj.x = projectedPoint.x
facObj.y = projectedPoint.y
I have a facObj that I just need to apply the xy planar coordinate values.
Solved! Go to Solution.
Solved with client-side esri/geometry/projection
projection.load().then(function (evt) {
const inSpatialReference = new SpatialReference({ wkid: 102100 });
const spSpatialReference = new SpatialReference({ wkid: 2881 });
const point = new Point(f.features[i].geometry, inSpatialReference);
var geoT = projection.getTransformation(inSpatialReference, spSpatialReference)
const projectedPoint = projection.project(point, spSpatialReference);
this.facObj.x = Math.round(projectedPoint.x);
this.facObj.y = Math.round(projectedPoint.y);
Solved with client-side esri/geometry/projection
projection.load().then(function (evt) {
const inSpatialReference = new SpatialReference({ wkid: 102100 });
const spSpatialReference = new SpatialReference({ wkid: 2881 });
const point = new Point(f.features[i].geometry, inSpatialReference);
var geoT = projection.getTransformation(inSpatialReference, spSpatialReference)
const projectedPoint = projection.project(point, spSpatialReference);
this.facObj.x = Math.round(projectedPoint.x);
this.facObj.y = Math.round(projectedPoint.y);