![](/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.