使用ArcGis Api为Javascript将Long和Lat转换为X Y坐标

时间:2017-12-05 12:38:52

标签: javascript gis arcgis-js-api

您好我正在尝试使用ArcGis Api将长,lat值转换为X,Y

Dim concatenated as String

Do While (Not rst.EOF)
   concatenated = concatenated + rst.Fields("Issuance Detail Description") + " "
   rst.MoveNext
Loop
concatenated = Left(concatenated, Len(concatenated) - 1)

在什么系统中进行此转换? 是否有指定投影系统的方法?

注意:转换是从十进制度到米

完成的

我跟着这个: https://developers.arcgis.com/javascript/3/jsapi/esri.geometry.webmercatorutils-amd.html

1 个答案:

答案 0 :(得分:5)

此方法用于将地理坐标系经度/纬度(wkid 4326)转换为投影坐标系Web Mercator(wkid 102100)。

默认esri地图使用Web Mercator作为投影系统。如果需要将坐标转换为其他坐标系,则需要使用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