我正在装载一层缆车。它加载正确,这就是定义:
map.addSource('aa_lifts', {
type: 'vector',
url: 'mapbox://'+ aa_lifts_source,
});
map.addLayer({
'id': 'aa_lifts',
'type': 'line', // background, fill, line, symbol, raster, circle, fill-extrusion, heatmap, hillshade, sky.
'source': 'aa_lifts', // from above
'source-layer': aa_lifts_source_layer,
'paint': {
'line-color': '#000',
'line-opacity': 1,
'line-width': 5,
'line-dasharray': [0, 2], // length of line and then length of gap.
},
'layout': {
'line-join': 'round',
'line-cap': 'round' //"butt", "round", "square" - default butt.
},
});
我最后想在缆车线路上添加一些图标,显示它是单人缆车、双人缆车、三人缆车还是儿子缆车。在我这样做之前,我以为我会让符号正常工作,但我遇到了一个奇怪的问题。如果我从 9.0 放大到 13.99,箭头会显示,但是,如果从 14 放大,它就会消失。我还有另一层小路,上面有名字。它也从 14 及更高版本中消失。我看不出我做错了什么,因此非常感谢任何指针或调试技术。
/** addLayer aa_lift **/
map.addLayer({
'id': 'aa_lifts_symbol',
'type': 'symbol', // background, fill, line, symbol, raster, circle, fill-extrusion, heatmap, hillshade, sky.
'source': 'aa_lifts', // from above
'source-layer': aa_lifts_source_layer,
"layout": {
"text-field": "►",
"text-size": 18,
"symbol-placement": "line-center",
"symbol-spacing": 10,
"text-rotation-alignment": "map",
"text-keep-upright": false
},
'paint': {
"text-color": [
"get",
"color"
]
},
});
您需要为源设置 maxZoom - 忘记它是 maxZoom 还是 maxZoom。一旦您将其设置为 14,它将仅使用该数据缩放级别并在后续缩放级别上显示它。这与在图层上设置最大缩放不同 - 这将在缩放后隐藏图层。