【问题标题】:OpenLayers tile-size 192OpenLayers 平铺大小 192
【发布时间】:2018-04-10 20:35:14
【问题描述】:

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

在 Microsoft Deep Zoom 格式中,例如。 G。图像为 7,360 x 4,912 像素(宽 x 高)。缩放级别为 0 - 13(13 是全分辨率图像)。在 OpenLayers 中,我将缩放级别设置为 0 = 8 Deep Zoom。在此缩放级别下,图像的分辨率为 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);
    });

【问题讨论】:

    标签: openlayers


    【解决方案1】:

    从 v4.5.0 开始,OpenLayers 将支持ol.source.ZoomifytileSize 选项。升级时,不要使用ol.source.XYZ,而只需使用ol.source.Zoomify 并使用tileSize 进行配置。

    【讨论】:

      猜你喜欢
      • 2012-07-29
      • 2014-07-08
      • 1970-01-01
      • 2014-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多