Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TileLayer support only load tiles in mask #2333

Merged
merged 14 commits into from
Jun 21, 2024
Merged

Conversation

deyihu
Copy link
Collaborator

@deyihu deyihu commented May 21, 2024

fix #2332

  • support TileLayer 256
  • support TileLayer 512
  • support PRESET-VT(512)
 const layer = new maptalks.TileLayer('base', {
            debug: true,
            // repeatWorld: false,
            // cascadeTiles:false,
            urlTemplate: "https://webst01.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}",
            urlTemplate: 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
            subdomains: ["a", "b", "c", "d"],
            maxAvailableZoom: 18,
            maskClip: false,
        });
   const polygons = maptalks.GeoJSON.toGeometry(geojson);
            layer.setMask(polygons[0]);
            layer.addTo(map);

@@ -52,7 +53,8 @@ const options: LayerOptionsType = {
'collisionScope': 'layer',
'hitDetect': (function () {
return !Browser.mobile;
})()
})(),
'maskClip': true
Copy link
Collaborator Author

@deyihu deyihu May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

mask不在是单纯的剪裁了,也可能用于tile filter

  • maskClip 开启剪裁
    一切交给用户来决定

@fuzhenn
Copy link
Member

fuzhenn commented Jun 13, 2024

总体没什么问题,但有几个可能的优化点:

  • 目前tileInfo中已经有了extent2d,即在tileInfo.res下的2d坐标,tile的bbox可以直接用他转换得到
  • mask的bbox是否可以用geometry的getExtent方法获得?这样可以不用引入geojson-bbox库

@deyihu
Copy link
Collaborator Author

deyihu commented Jun 14, 2024

总体没什么问题,但有几个可能的优化点:

  • 目前tileInfo中已经有了extent2d,即在tileInfo.res下的2d坐标,tile的bbox可以直接用他转换得到
  • mask的bbox是否可以用geometry的getExtent方法获得?这样可以不用引入geojson-bbox库

问题已经解决 @fuzhenn

@fuzhenn
Copy link
Member

fuzhenn commented Jun 19, 2024

关于options.maskCliponlyLoadTilesInMask,我感觉增加的这两个options并不是特别必要,列举一下这两个设置不同情况下的作用:

  • maskClip不开启,onlyLoadTilesInMask不开启,设置的mask不起任何作用,瓦片也全都载入,相当于不设置mask
  • maskClip不开启,onlyLoadTilesInMask开启,地图上绘制显示与mask相交的tiles,但所有瓦片形状均完整,有什么场景会用到?
  • maskClip开启,onlyLoadTilesInMask开启,即最优的情况
  • maskClip开启,onlyLoadTilesInMask不开启,载入所有瓦片,地图只显示mask范围内瓦片,即上面情况的性能更差版

综上,上述四种情况似乎并没有带来很明显的业务灵活性,所以我建议去掉这两个设置,只要setMask,就相当于maskClip和onlyLoadTilesInMask生效。

@deyihu
Copy link
Collaborator Author

deyihu commented Jun 19, 2024

  • maskClip不开启,onlyLoadTilesInMask开启,地图上绘制显示与mask相交的tiles,但所有瓦片形状均完整,有什么场景会用到?

这个还是有应用场景的,典型的场景:瓦片计算和下载,比如下载上海市市的瓦片,各种软件和网站都会将这个区域覆盖的瓦片显示出来的

BG%UU8~`897@)KU5OFV3

R(%N16NF}_7GXJW%J0VVR(7

@deyihu
Copy link
Collaborator Author

deyihu commented Jun 19, 2024

我仔细想了下 onlyLoadTilesInMask可以去掉,但是maskClip得保留

@fuzhenn fuzhenn merged commit d5ac56b into maptalks:master Jun 21, 2024
1 check passed
@deyihu deyihu deleted the 2332 branch June 21, 2024 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

only load tiles in mask
2 participants