doubleee

GeometryService Project method...problem

Discussion created by doubleee on Oct 26, 2013
Hello again!

I recently wrote about trying to convert X and Y coordinates (in RT90) to lat and lng.
Ken Buja helped me a lot by showing me a modified version of the "Project a point" sample which uses a GeometryService.

I got most of it to work and now I'm trying to simplify and strip down the code do for me to use when doing an API call.

But I'm stuck.... I get an error saying that the project method is undefined.
Does anyone see in the code below if I somehow need to change my arguments when calling the Project method of the esri.tasks.GeometryService class?

As always, help is very much appreciated!
I'm a newbie.... you might have figured out that already...:)

Thanks for your time
/Erik

require("esri.SpatialReference");
require("esri.tasks.GeometryService");
require("esri.tasks.ProjectParameters");

gsvc = new esri.tasks.GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");  

function projectToLatLong() {

  var outSR = new esri.SpatialReference(4326);
  var inputpoint =  new esri.geometry.Point(1630111/*Y-test coord*/,6570898/*X-test coord*/, new esri.SpatialReference({ wkid: 3021 })); 
  var params = new esri.tasks.ProjectParameters();
       
      params.geometries = [inputpoint]; 
      params.outSR = outSR;
      
      gsvc.project(params, function(projectedPoints) {
      pt = projectedPoints[0];
      return(pt.Y.toFixed(5),pt.X.toFixed(5));
 }); 

};

Outcomes