【发布时间】:2020-05-28 09:35:43
【问题描述】:
我正在尝试通过 ['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,但也出现错误。告诉我如何解决这个问题。
【问题讨论】:
标签: javascript mapbox mapbox-gl-js mapbox-gl