使用 ArcGis Api For Javascript 将 Long 和 Lat 转换为 X Y 坐标
Convert Long And Lat to X Y coordinate using ArcGis Api For Javascript
您好,我正在尝试使用 ArcGis Api 将经纬度值转换为 X、Y Javascript
var i = esri.geometry.lngLatToXY(3.13, 36.742)
console.log(i); //returns Array [ 348541.32567373366, 4403205.668961807 ]
这种转换发生在什么系统中?
有指定投影系统的方法吗?
注意:转换是从十进制度到米
我关注了这个:
https://developers.arcgis.com/javascript/3/jsapi/esri.geometry.webmercatorutils-amd.html
此方法用于将地理坐标系 longitude/latitude (wkid 4326) 转换为投影坐标系 Web Mercator (wkid 102100)。
默认 esri 地图使用 Web 墨卡托作为投影系统。如果需要将坐标转换为其他坐标系,则需要使用 GeometryService 的 project
方法:
https://developers.arcgis.com/javascript/3/jsapi/geometryservice-amd.html
示例:
require(["esri/geometry/Point", "esri/tasks/GeometryService", "esri/tasks/ProjectParameters", "esri/SpatialReference", "dojo/domReady!"],
function(Point, GeometryService, ProjectParameters, SpatialReference) {
var outSR = "YOUR_OUTPUT_COORDINATE_SYSTEM"; // `wkid {number}`
var geometryService = new GeometryService("https://utility.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
var inputpoint = new Point({
longitude: "YOUR_LONGITUDE_INPUT",
latitude: "YOUR_LATITUDE_INPUT"
});
var projectParams = new ProjectParameters();
projectParams.geometries = [inputpoint];
projectParams.outSR = new SpatialReference({ wkid: outSR });
geometryService.project(projectParams, (result) => {
let outputpoint = result[0]; // outputpoint first element of result array
console.log("Result x:", outputpoint.x, "y :", outputpoint.y);
});
});
Wkid 号码可以在这里找到:
编辑
这是一个工作示例:Plunker
您好,我正在尝试使用 ArcGis Api 将经纬度值转换为 X、Y Javascript
var i = esri.geometry.lngLatToXY(3.13, 36.742)
console.log(i); //returns Array [ 348541.32567373366, 4403205.668961807 ]
这种转换发生在什么系统中? 有指定投影系统的方法吗?
注意:转换是从十进制度到米
我关注了这个: https://developers.arcgis.com/javascript/3/jsapi/esri.geometry.webmercatorutils-amd.html
此方法用于将地理坐标系 longitude/latitude (wkid 4326) 转换为投影坐标系 Web Mercator (wkid 102100)。
默认 esri 地图使用 Web 墨卡托作为投影系统。如果需要将坐标转换为其他坐标系,则需要使用 GeometryService 的 project
方法:
https://developers.arcgis.com/javascript/3/jsapi/geometryservice-amd.html
示例:
require(["esri/geometry/Point", "esri/tasks/GeometryService", "esri/tasks/ProjectParameters", "esri/SpatialReference", "dojo/domReady!"],
function(Point, GeometryService, ProjectParameters, SpatialReference) {
var outSR = "YOUR_OUTPUT_COORDINATE_SYSTEM"; // `wkid {number}`
var geometryService = new GeometryService("https://utility.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
var inputpoint = new Point({
longitude: "YOUR_LONGITUDE_INPUT",
latitude: "YOUR_LATITUDE_INPUT"
});
var projectParams = new ProjectParameters();
projectParams.geometries = [inputpoint];
projectParams.outSR = new SpatialReference({ wkid: outSR });
geometryService.project(projectParams, (result) => {
let outputpoint = result[0]; // outputpoint first element of result array
console.log("Result x:", outputpoint.x, "y :", outputpoint.y);
});
});
Wkid 号码可以在这里找到:
编辑
这是一个工作示例:Plunker