var stopGeometry = new Point({
x:e.x,
y:e.y
});
My map is of wkid 27700. I'm using RouteTasks and have a point of wkid 27700 I need the directions from. I have an x and y target value so I'm making a new Point like above. The problem is this Point has a wkid of 4326. How can I change this to 27700? I tried stopGeometry.spatialReference.wkid = 27700; but that doesn't work. The API reference for Point doesn't mention being able to change the spatial reference wkid.
Solved! Go to Solution.
Solved by using the .copy function of Point
var stopGeometry = new Point();
stopGeometry.copy(otherGeometry);
stopGeometry.x = e.x;
stopGeometry.y = e.y;
Solved by using the .copy function of Point
var stopGeometry = new Point();
stopGeometry.copy(otherGeometry);
stopGeometry.x = e.x;
stopGeometry.y = e.y;
The proper way to do what you were attempting originally is:
var stopGeometry = new Point({
x:e.x,
y:e.y,
spatialReference: new SpatialReference({wkid:27700})
});