maptalks / maptalks.js

A light and plugable JavaScript library for integrated 2D/3D maps.
https://maptalks.org
BSD 3-Clause "New" or "Revised" License
4.25k stars 497 forks source link

加载使用Maperitive生成瓦片,计算出的坐标有很大偏移 #566

Closed wangbincumt closed 6 years ago

wangbincumt commented 6 years ago

使用Maperitive把osm格式的地图生成瓦片,epsg 4326坐标系。 使用maptalks加载

 var map = new maptalks.Map('map', {
        center: [110.12566499991837,39.579402956962682],
          zoom: 18,
          minZoom : 18,
          maxZoom : 19,
        spatialReference:{
          projection:'EPSG:4326'
        },
        baseLayer: new maptalks.TileLayer('base', {
          tileSystem : [1, 1, -180, -90],
          urlTemplate:'http://localhost/tiles/{z}/{x}/{y}.png',
           subdomains:['18', '19']
        }),

        attribution : {
          content : '&copy; <a target="_blank" href="http://www.tianditu.cn">Tianditu</a>'
        }
      });

其中y坐标总是有很大偏移。Title中y是99639,99640。maptalks需要加载的是94300左右。这样瓦片显示错误。

使用Leaflet,能正常加载

请问怎么处理这种问题

fuzhenn commented 6 years ago

sorry,刚才理解错了 这种情况需调整tileSystem中的值,[1, 1, -180, -90]是天地图4326瓦片的设置,不一定适用你的瓦片 [1, 1, -180, -90]每一位的含义: 0: x轴的瓦片编号规则,从左到右递增则为1, 反之为-1 1: y轴的瓦片编号规则,从下到上递增则为1, 反之为-1 2: 瓦片的起始投影坐标点的x值,同arcgis中的tile origin 3: 瓦片的起始投影坐标点的y值,同arcgis中的tile origin

具体请见这篇Tile System的详细介绍 https://github.com/maptalks/maptalks.js/wiki/Tile-System

fuzhenn commented 6 years ago

根据leaflet里的说明 可以试一下这个tile system设置:

[1, -1, -180, 90]
fuzhenn commented 6 years ago

@wangbincumt closing, will reopen if necessary.