简体   繁体   English

使用Java的ArcGis Api将经纬度转换为XY坐标

[英]Convert Long And Lat to X Y coordinate using ArcGis Api For Javascript

Hello i'm trying to convert long,lat values to X,Y using ArcGis Api For Javascript 您好,我正在尝试使用ArcGis Api For Javascript将较长的经度值转换为X,Y

 var i = esri.geometry.lngLatToXY(3.13, 36.742)
 console.log(i); //returns Array [ 348541.32567373366, 4403205.668961807 ]

in what system does this conversion take place? 转换在什么系统上进行? is there a method to specify the projection system? 有没有指定投影系统的方法?

note: the conversion is done from decimal degree to meters 注意:转换是从十进制度到米

i followed this : https://developers.arcgis.com/javascript/3/jsapi/esri.geometry.webmercatorutils-amd.html 我遵循了这个: https : //developers.arcgis.com/javascript/3/jsapi/esri.geometry.webmercatorutils-amd.html

This method is used to convert geographic coordinate system longitude/latitude (wkid 4326) to projected coordinate system Web Mercator (wkid 102100). 此方法用于将地理坐标系的经度/纬度(wkid 4326)转换为投影坐标系Web Mercator(wkid 102100)。

Default esri map use Web Mercator as projection system. 默认的esri地图使用Web Mercator作为投影系统。 If you need to convert your coordinates to an other coordinate system you need to use the project method of GeometryService : https://developers.arcgis.com/javascript/3/jsapi/geometryservice-amd.html 如果需要将坐标转换为其他坐标系,则需要使用GeometryService的project方法: https : //developers.arcgis.com/javascript/3/jsapi/geometryservice-amd.html

Example: 例:

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 numbers can be found here: Wkid号码可以在这里找到:

EDIT 编辑

Here is a working example: Plunker 这是一个工作示例: Plunker

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM