![](/img/trans.png)
[英]How to change line-dasharray settings in MapboxGL using user properties?
[英]How to get 'line-dasharray' value from geojson for mapbox GL
我正在嘗試通過 ['get', 'line-dasharray'] 獲取值,但出現錯誤
這是我的代碼
var data = {
'type': 'FeatureCollection',
'features': [
{
'type': 'Feature',
'geometry': {
'type': 'LineString',
'coordinates': []
},
'properties': {
'route_id': 300,
'route_url': 'http://test.com/file.gpx',
'line-color': '#426d7e',
'line-width': 3,
'line-opacity': 1,
'line-dasharray': [5, 2]
},
},
]
}
// some code
map.addSource('locations-rote', {
type: 'geojson',
data: data,
generateId: true
});
map.addLayer({
'id': 'route-coordinates',
'type': 'line',
'source': 'locations-rote',
'layout': {
'line-join': 'round',
'line-cap': 'round'
},
'paint': {
'line-color': ['get', 'line-color'],
'line-width': ['get', 'line-width'],
'line-opacity': ['get', 'line-opacity'],
'line-dasharray': ['get', 'line-dasharray']
}
});
我嘗試使用數組表達式 - https://docs.mapbox.com/mapbox-gl-js/style-spec/expressions/#types-array但也出現錯誤。 告訴我如何解決問題。
Mapbox 在 2.3.0 版上支持數據驅動屬性“line-dasharray”。 您可以更新 sdk 版本。
有關詳細信息,請參閱github 問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.