码迷,mamicode.com
首页 > 其他好文 > 详细

leaflet-加载天地图-解决纬度偏移特别大

时间:2018-07-06 23:27:13      阅读:839      评论:0      收藏:0      [点我收藏+]

标签:label   异常   orm   90度   https   现在   没有   配置   utf-8   

这几天学习leaflet在加载天地图时将以前的接口拿来用结果偏差了特别大(差不多是90度),中国纬度到了100多,试了改变投影和y轴翻转的配置都不好使,最后上网搜索到了Leaflet.ChineseTmsProviders(MapGIS的示例也是用的它)查看他的用法发现我用的天地图接口和它不一样,改成它的接口就不会出现纬度偏移特别大的问题了(到现在也没有搜到cva_w和vec_c这两个接口的区别,CGCS200和WGS48么?那也差不了那么多啊!以后找到区别再写上来吧)

正常的:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css"
  integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ=="
  crossorigin=""/>
  <style>
   #mapid { height: 500px; }
  </style>
</head>
<body>
  <div id="mapid"></div>
  <script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"
   integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw=="
   crossorigin=""></script>
  <script>
    var normalm = L.tileLayer(‘http://t{s}.tianditu.cn/DataServer?T=vec_w&X={x}&Y={y}&L={z}‘, {
        subdomains: [‘0‘, ‘1‘, ‘2‘, ‘3‘, ‘4‘, ‘5‘, ‘6‘, ‘7‘],
    });
    stamenLabels = L.tileLayer(‘http://t{s}.tianditu.cn/DataServer?T=cva_w&X={x}&Y={y}&L={z}‘, {
      subdomains: [‘0‘, ‘1‘, ‘2‘, ‘3‘, ‘4‘, ‘5‘, ‘6‘, ‘7‘]
    });

    var map = L.map("mapid", {
      center: [31.59, 120.29],
      zoom: 12,
      layers: [normalm],
      zoomControl: false
    });
    stamenLabels.addTo(map);
  </script>
</body>
</html>

异常的:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css"
  integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ=="
  crossorigin=""/>
  <style>
   #mapid { height: 500px; }
  </style>
</head>
<body>
  <div id="mapid"></div>
  <script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"
   integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw=="
   crossorigin=""></script>
  <script>
    var normalm = L.tileLayer(‘http://t{s}.tianditu.cn/DataServer?T=vec_c&X={x}&Y={y}&L={z}‘, {
        subdomains: [‘0‘, ‘1‘, ‘2‘, ‘3‘, ‘4‘, ‘5‘, ‘6‘, ‘7‘],
    });
    stamenLabels = L.tileLayer(‘http://t{s}.tianditu.cn/DataServer?T=cva_c&X={x}&Y={y}&L={z}‘, {
      subdomains: [‘0‘, ‘1‘, ‘2‘, ‘3‘, ‘4‘, ‘5‘, ‘6‘, ‘7‘]
    });

    var map = L.map("mapid", {
      center: [31.59, 120.29],
      zoom: 12,
      layers: [normalm],
      zoomControl: false
    });
    stamenLabels.addTo(map);
  </script>
</body>
</html>

leaflet-加载天地图-解决纬度偏移特别大

标签:label   异常   orm   90度   https   现在   没有   配置   utf-8   

原文地址:https://www.cnblogs.com/jffun-blog/p/9275769.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!