美文网首页Cesium
arcgis js api:web墨卡托(3857)转经纬度坐标

arcgis js api:web墨卡托(3857)转经纬度坐标

作者: gis杭州 | 来源:发表于2018-05-17 15:49 被阅读640次

转换前:


image.png

转换后:


image.png

示例代码:

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
  <title>webMercatorUtils</title>
  <link rel="stylesheet" type="text/css"
        href="https://js.arcgis.com/3.23/esri/css/esri.css"/>
  <script src="https://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
  <script type="text/javascript" src="https://js.arcgis.com/3.23/init.js"></script>
  <style>
    html, body, #map {
      height: 100%;
      margin: 0;
      padding: 0;
    }
  </style>

  <script>
    var map;
    require(["esri/map","dojo/on",
      "esri/geometry/webMercatorUtils", "dojo/domReady!"],
      function (Map, on, webMercatorUtils) {
      map = new Map("map", {
        zoom: 10,
        maxZoom: 18,
        // minZoom: 8,
        center: [120.243, 30.256],
        // center: [120.313, 36.206],
        logo: false
      });

      var geoqtiledUrl = "http://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetPurplishBlue/MapServer";

      var geoqTiledLayer = new esri.layers.ArcGISTiledMapServiceLayer(geoqtiledUrl);


      map.addLayer(geoqTiledLayer);

      on(map, "click", function (event) {
        var value = webMercatorUtils.webMercatorToGeographic(event.mapPoint);
        console.log(value);
      })
    });
  </script>
</head>

<body>
<div id="map"></div>
</body>
</html>

参考api文档:
https://developers.arcgis.com/javascript/3/jsapi/esri.geometry.webmercatorutils-amd.html

另外:openlayers提供的坐标转换供参考
http://anzhihun.coding.me/ol3-primer/ch05/05-09.html

相关文章

网友评论

    本文标题:arcgis js api:web墨卡托(3857)转经纬度坐标

    本文链接:https://www.haomeiwen.com/subject/bqgbdftx.html