OpenLayers瓷砖大小192

时间:2017-10-29 21:40:19

标签: openlayers

我不明白这一点:我正在使用高分辨率图像的OpenLayers,我以Microsoft Deep Zoom格式平铺。这适用于256x256像素的瓷砖。但是,我也有图像平铺192x192像素瓷砖。

在Microsoft Deep Zoom格式中,e。 G。图像为7,360 x 4,912像素(宽x高)。有缩放级别0 - 13(13是全分辨率图像)。在OpenLayers中,我设置缩放级别0 = 8深度缩放。在此缩放级别,图像的分辨率为230 x 154像素。使用256x256像素图块,OpenLayers只能在缩放级别0上正确请求一个图块,然后在缩放级别1上正确请求4个图块,依此类推。

然而,对于192x192的图块,它会从缩放级别0加载4个图块(其中2个不存在)。你有解决方案吗?

    function startOL(tileinput){
       var TileSize = tileinput;
       var MaxZoom = 5;
       var MinZoom = 0;
       //var PyramidWidth = TileSize * (1 << MaxZoom);
       var width = 12288;//7360
       var height = 4912;//4912;
       var extent = [0, 0, width, height];
       var center = ol.extent.getCenter(extent);

       var projection = new ol.proj.Projection({
           code: 'pixels',
           units: 'pixels',
           extent: extent
       });


       var map = new ol.Map({
           target: 'map',
           controls: ol.control.defaults({attribution: false}),
           layers: [
               new ol.layer.Tile({
                   wrapX: false,
                   extent: [0, 0, width , height],
                   source: new ol.source.XYZ({
                       tileUrlFunction: function(tileCoord, pixelRatio, projection){
                           if (!tileCoord) { return ""; }
                           // tileCoord is representing the location of a tile in a tile grid (z, x, y)
                           var z = tileCoord[0];
                           var x = tileCoord[1].toString();
                           var y = tileCoord[2].toString();

                           // add the part /1/1-0.jpg, --> {z}/{x}-{y}.jpg
                           z = z+7;
                           var path = "./EY1_2481-"+tileinput.toString()+"/EY1_2481-"+tileinput.toString()+"_files";
                           path += '/' + z.toString() + '/' + x + '_' + y + '.jpeg';
                           return path;
                       },
                       maxZoom: MaxZoom,
                       minZoom: MinZoom,
                       projection: projection,
                       tileSize: TileSize,
                       logo:false
                   })
               })
           ],
           view: new ol.View({
               center: ol.extent.getCenter(extent),
               zoom: 0,
               maxZoom: MaxZoom,
               minZoom: MinZoom,
               projection: projection
               // maxResolution:maxRes
           })
       });


   }

    $('#256').click(function(){
        $('.ol-viewport').remove();
        $('#size').text('256');
       startOL(256);
    });
    $('#192').click(function(){
        $('.ol-viewport').remove();

        $('#size').text('192');
        startOL(192);
    });

1 个答案:

答案 0 :(得分:0)

从v4.5.0开始,OpenLayers将支持tileSize的{​​{1}}选项。升级时,不要使用ol.source.Zoomify,只需使用ol.source.XYZ并使用ol.source.Zoomify对其进行配置。