我使用 Mapbox GL Draw,我想使用数据驱动自定义 LineString Feature 的填充颜色。我有一个集合userProperties: true
,我有一个以 user_ 为前缀的属性。
这是我的风格配置:
{
id: "gl-draw-linestring-fill-inactive",
type: "fill",
filter: ["all", ["==", "active", "false"], ["==", "$type", "LineString"],["!=", "mode", "static"],],
paint: {
"fill-color": [
"case",
["==", ["get", "user_type"], "meetingRoom"],
"#00ff00",
["==", ["get", "user_type"], "notUsed"],
"#00ff00",
"#ff0000",
],
"fill-outline-color": "#3bb2d0",
"fill-opacity": 0.4,
},
}
和我的特点:
{
"type": "Feature",
"id": "ROOM-floor-1-1",
"properties": {
"parentId": "floor-1",
"user_type": "notUsed"
},
"geometry": {
"coordinates": [
[2.334699793548168, 48.85506145052912],
[2.3334337908935083, 48.85340956808176],
[2.3360301692199243, 48.85314130852265],
[2.3368884761040363, 48.85547088304844],
[2.3368884761040363, 48.85547088304844],
[2.334699793548168, 48.85506145052912]
],
"type": "LineString"
}
}
功能始终使用默认值 (#ff0000) 绘制。在这个例子中它应该是#00ff00。在同一个应用程序中,我使用相同的属性(user_type)在多边形上设置线条颜色,它工作正常!
任何想法 ?