我的geoJson数据如下:
features: [{
geometry: { type: "Point", coordinates: Array(2) }
properties: { id: 1, status: "deselected" }
type: "Feature"
},
{
geometry: { type: "Point", coordinates: Array(2) }
properties: { id: 3, status: "selected" }
type: "Feature"
} {
geometry: { type: "Point", coordinates: Array(2) }
properties: properties: { id: 4, status: "deselected" }
type: "Feature"
}
]
我已将其添加为图层,并且可以使用get
和match
函数根据状态将圆圈从红色更改为绿色
const LAYERINFO = {
id: "unclustered-point",
type: "circle",
source: "geoJsonSample",
filter: ["!", ["has", "point_count"]],
paint: {
"circle-radius": 6,
"circle-color": [
"match",
["get", "status"],
"selected",
"green",
"deselected",
"red",
"#ccc" //other
]
}
};
这是我感到难过的地方。如何使用它来更新图像?我想根据状态更新icon-image
,但不确定如何执行。
const UNCLUSTERED_LAYER = {
filter: ["!", ["has", "point_count"]],
id: "unclustered-point",
source: "earthquakes",
type: "symbol",
layout: {
"icon-image": "marker2",
"icon-allow-overlap": true,
"icon-size": 0.06
}