本文主要是介绍mapbox的Source,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
- 问题情景:矢量图层层级4-8,地图缩放到9,矢量地图数据不显示了。如何保留上一层级数据在地图上呢?
- 解决:添加Source时设置maxzoom或minzoom属性。如矢量图层层级4-8设置为:
map.on('load', function() {// 添加数据源map.addSource('aero_navdata', {"type": "vector",'tiles': ['https://d116.foht.com/tileserver/resources/aero_navdata_2404/tiles/{z}/{x}/{y}?v=1713028420.2392&Key-Pair-Id=K3B6LIRZIHY0OC&Policy=eyJTdGF0'],maxzoom: 8, //必须设置并且最大或最小需不得大于或小于矢量图层,否则地图层级超出矢量图层层级时,地图上不会显示。minzoom: 4,});map.addLayer({"id": "Airway Airspace - World","layout": {},"metadata": {"group": "TMA/TCA"},maxzoom: 22,minzoom: 4,"paint": {"line-color": "hsla(206, 97%, 34%, 0.3)","line-offset": {"base": 1,"stops": [[0,0],[22,7.5]]},"line-opacity": {"base": 1,"stops": [[5,0],[6,1]]},"line-width": {"base": 1,"stops": [[6,1.5],[9,10]]}},"source": "aero_navdata","source-layer": "airspaces","type": "line"})map.addLayer({"id": "TRSA","layout": {"symbol-placement": "line","symbol-spacing": {"base": 1,"stops": [[0,600],[12,1000]]},"text-field": "{ac}-{res}-{t}-{ll_raw}","text-font": ["Open Sans Bold"],"text-letter-spacing": 0.05,"text-offset": [0,0.75],"text-size": {"base": 1,"stops": [[8,14],[12,16]]},"line-cap": "round","line-join": "round","visibility": "visible",},"metadata": {"group": "Airspace Labels - Controlled"},"minzoom": 8,"paint": {"text-color": "#fff","text-halo-color": "#0362aa","text-halo-width": 2},"source": "aero_navdata","source-layer": "airspaces","type": "symbol"})});
后续使用补充Source 中属性。
这篇关于mapbox的Source的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!