POST
|
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));
});
};
... View more
10-26-2013
02:32 PM
|
0
|
0
|
597
|
POST
|
Ken, I really appreciate your help and effort! I understand most of your answer but I'm kind of stuck on a big thing.... How would I pass my X Y coordinates to the function projectToWebMercator? For instance a real simple example would be, how would I pass my previously mentioned X= 6570898 Y = 1630111 to the function? Do I somehow push them into the mapPoint object? Sorry but I just cant figure it out. But I'm really glad there is people like you who help. Because one learns alot! function projectToWebMercator(evt) { var point = evt.mapPoint; Best Erik
... View more
10-23-2013
01:47 PM
|
0
|
0
|
575
|
POST
|
Hi! I'm a newbie to coordinates, so any help with my question is much appreciated. 🙂 I???m having trouble converting X Y coordinates (RT90) to lat and lng (I think it???s called WGS84?). I'm using an API that returns X and Y coordinates and I get quite strange results when calling the esri.geometry.xyToLngLat(long,lat) method. For example when I pass X= 6570898 Y = 1630111 (a bit south of Stockholm, Sweden) the method should return lat: 59.239121, lng: 18,085032. But instead the esri.geometry.xyToLngLat method returns lat: 59.02738103790395 lng: 14.486671705724888. Which is very very far west of Stockholm Sweden???.. As I said, I???m a newbie. What I???m I doing wrong? 🙂 Any help, much appreciated! Kind regards /Erik
... View more
10-21-2013
11:56 PM
|
0
|
2
|
2444
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|