4.9: Specify the spatial reference of a new Point?

268
2
Jump to solution
12-07-2018 02:22 AM
ShakilChoudhury
New Contributor III
      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. 

0 Kudos
1 Solution

Accepted Solutions
ShakilChoudhury
New Contributor III

Solved by using the .copy function of Point

var stopGeometry = new Point();
stopGeometry.copy(otherGeometry);
stopGeometry.x = e.x;
stopGeometry.y = e.y;‍‍‍‍

View solution in original post

0 Kudos
2 Replies
ShakilChoudhury
New Contributor III

Solved by using the .copy function of Point

var stopGeometry = new Point();
stopGeometry.copy(otherGeometry);
stopGeometry.x = e.x;
stopGeometry.y = e.y;‍‍‍‍

View solution in original post

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

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})
});‍‍‍‍‍