【问题标题】:OL5 VectorTileLayer: Y coordinate of tileOL5 VectorTileLayer:瓦片的Y坐标
【发布时间】:2018-09-09 07:18:27
【问题描述】:

我尝试将 OL5 矢量切片与全局切片网格一起使用。

import 'ol/ol.css'
import { Map, View } from 'ol'
import MVT from 'ol/format/MVT'
import TileGrid from 'ol/tilegrid/TileGrid'
import VectorTileLayer from 'ol/layer/VectorTile'
import VectorTileSource from 'ol/source/VectorTile'

let zoom = 0
let center = [8531000, 5342500]
let resolutions = [
    9.554628535647032,
    4.777314267823516,
    2.388657133911758,
    1.19432856695588,
]
let extent = [0, 0, 20037508.342789244, 20037508.342789244]

const map = new Map({
    target: 'map',
    view: new View({
        zoom: zoom,    
        center: center,
        resolutions: resolutions,
   })     
})

const vectorTiles = new VectorTileLayer({
    source: new VectorTileSource({
        tileSize: 256,
        projection: 'EPSG:3857',
        format: new MVT(),    
        tileGrid: new TileGrid({      
            extent: extent,          
            resolutions: resolutions,
        }),    
        url: 'http://localhost:8000/get-vector-tiles/{z}/{x}/{y}'
    })   
 })

 map.addLayer(vectorTiles)

一个请求看起来像http://localhost:8000/get-vector-tiles/0/3487/6007, 据我了解{x}/{y} 是来自原点的图块的坐标(数字)(在我的情况下为0,0)。

起始分辨率为9.554628535647032, 因此图块大小为9.554628535647032 × 256 = 2445.984905126

请求区域坐标的估计:

X:2445.984905126 × 3487 = 8529149.3642

Y:2445.984905126 × 6007 = 14693031.2943

考虑到地图的中心是[8531000, 5342500]

X坐标正确8529149.3642 ~ 8531000, 而Y坐标不匹配5342500 vs 14693031.2943

怎么了?

【问题讨论】:

    标签: vector grid tile openlayers-5


    【解决方案1】:

    解决了,问题是从左上角开始渲染,所以20037508.342789244 - 2445.984905126 × 6007 ~ 5342500,好吧!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-03
      • 2013-05-05
      • 1970-01-01
      • 2015-05-23
      相关资源
      最近更新 更多