简体   繁体   English

OpenLayers 3,静态切片和XYZ坐标

[英]OpenLayers 3, static tiles and XYZ coordinates

The goal is to be able to zoom onto a high-res picture (11520x11520) that I have split into 256x256 squares. 我们的目标是能够放大我分成256x256方格的高分辨率图像(11520x11520)。 I took the large image and resized it to 80%, 60%, 40%, 20% and 8.89%. 我拍摄了大图,并将其调整为80%,60%,40%,20%和8.89%。 Then, for each of the images from 100% to 8.89%, I split them. 然后,对于每个图像从100%到8.89%,我将它们分开。 It's to make an interactive video game map like this: http://www.ark-survival.net/en/dynamic-livemap/ 这是制作这样的互动视频游戏地图: http//www.ark-survival.net/en/dynamic-livemap/

I have tried this: 我试过这个:

var map = new ol.Map({
    target: 'ark_map',
    layers: [
        new ol.layer.Tile({
        source: new ol.source.XYZ({
                url: 'images/map/{z}/map_{x}_{y}.png',
                tileSize: 256,
                maxZoom: 5
            })
        })
    ],
    view: new ol.View({
        center: [50, 50],
        zoom: 5,
        minZoom: 0
    })
});

The result: I only see the top left corner on any zoom used. 结果:我只看到所用缩放的左上角。 I've seen many examples and many questions, but combining static tiles and XYZ (on pixels) has never come up. 我已经看过很多例子和很多问题,但结合静态图块和XYZ(像素)从未出现过。

Here is the JS Fiddle . 这是JS小提琴

How do you combine static tiles and XYZ coordinates based on a pixel system? 如何基于像素系统组合静态切片和XYZ坐标?

You have a very weird tile layout. 你有一个非常奇怪的瓷砖布局。 What you describe maps to this set of resolutions: 您描述的内容映射到这组解决方案:

var resolutions = [
  45/4,
  45/4/2*0.889,
  45/4/4*0.889,
  45/4/6*0.889,
  45/4/8*0.889
];

With that, you can configure an ol.tilegrid.TileGrid : 有了它,您可以配置ol.tilegrid.TileGrid

new ol.tilegrid.TileGrid({
  origin: [0, 11520],
  resolutions: resolutions
})

See updated fiddle for the full code: https://jsfiddle.net/6moqu7q8/4/ . 有关完整代码,请参阅更新的小提琴: https//jsfiddle.net/6moqu7q8/4/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM