如何使用带有mapproxy的openlayer版本4创建wmts服务

时间:2018-06-30 05:50:59

标签: openlayers

我与geoserver发布了地图,并且将mapproxy用于wmts服务。 mapproxy已经获得了openlayer版本2的示例,我想使用openlayer版本4,但该版本4无效。

这是带有openlayer2的mapproxy样本

import java.util.concurrent.ThreadLocalRandom;

public class MyClass {
    public static void main(String args[]) {
        System.out.println(ThreadLocalRandom.current().nextDouble(0.5, 0.6));
    }
}

这是我的openlayer版本4的示例代码,不适用于此版本

var map;
var mapOptions = {
projection: new OpenLayers.Projection('EPSG:3857'),
resolutions: [156543.03392804097, 78271.51696402048, 39135.75848201024,
19567.87924100512, 9783.93962050256, 4891.96981025128, 2445.98490512564, 
1222.99245256282,
611.49622628141, 305.748113140705, 152.8740565703525, 76.43702828517625,
38.21851414258813, 19.109257071294063, 9.554628535647032, 4.777314267823516,
2.388657133911758, 1.194328566955879, 0.5971642834779395, 
0.29858214173896974],
units: 'm',
maxExtent: new OpenLayers.Bounds(-20037508.342789244, -20037508.342789244,
20037508.342789244, 20037508.342789244),
tileSize: new OpenLayers.Size(256, 256)
};

map = new OpenLayers.Map('map', mapOptions);

var layer = new OpenLayers.Layer.WMTS({
 name: "WMTS osm",
 url: '../wmts/osm/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.png',
 layer: 'osm',
 matrixSet: 'webmercator',
 format: 'png',
 isBaseLayer: true,
 style: 'default',
 requestEncoding: 'REST'
});

map.addLayer(layer)

请帮助我

1 个答案:

答案 0 :(得分:0)

这就是我对开放式第6层所做的;

我还使用Proj4转换了OSM底图。

提示:

我通过以下控制台命令获得center的{​​{1}}和resolution参数;

ol.Viewmap.getView().getResolution()

在查看地图时,可以在浏览器的控制台中调用这些命令。

map.getView().getCenter()