[英]How to get 'line-dasharray' value from geojson for mapbox GL
[英]How to change line-dasharray settings in MapboxGL using user properties?
我嘗試使用以下代碼更改 line-dasharray 設置,
'line-dasharray': [
"case",
['==', ['get', "user_class_id"], 'laneway'],[0.2,2],[0.3,2]
]
它給出了這個錯誤,
Error: layers.gl-draw-line-active.hot.paint.line-dasharray[2][0]: Expression name must be a string, but found number instead. If you wanted a literal array, use ["literal", [...]].
所以我根據錯誤建議修復了代碼,
'line-dasharray': [
"case",
['==', ['get', "user_class_id"], 'laneway'],['literal',[0.2,2]],['literal',[0.3,2]]
]
它給了我這個錯誤,
evented.js:136 Error: layers.gl-draw-line-active.hot.paint.line-dasharray: data expressions not supported
有誰知道如何解決這個問題?
請參閱https://docs.mapbox.com/mapbox-gl-js/style-spec/#paint-line-line-dasharray上的 API 文檔。 不支持 line-dasharray 的數據驅動樣式。
在https://github.com/mapbox/mapbox-gl-js/issues/3045上存在一個關於此支持的未解決問題,您可以按照該問題進行更新。
同時,您可以將此層拆分為具有不同過濾器的幾層,以實現相同的結果。
對於任何人來說,從 v2.3 開始支持數據驅動的 line-dasharrays
例子:
"paint": {
"line-dasharray": [
"match", ["get", "property"],
1, ["literal", [1, 2]],
2, ["literal", [2, 2]],
3, ["literal", [3, 2]],
["literal", [1, 1]]
]
},
"layout": {
"line-cap": ["match", ["get", "property"], 2, "round", "butt"]
}
從這里: https ://github.com/mapbox/mapbox-gl-js/pull/10591
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.