"filter":["==",["get","name"],"海淀区"]},{"id":"beijing-chaoyang","type":"fill","source":"beijing","paint":{"fill-color":"#FFCCCC"},"filter":["==",["get","name"],"朝阳区"]}...]
方式三:分图层设置 {"id":"beijing200plus","type":"fill","source":"beijing","paint":{"fill-color":"#b50a09"},"filter":['>=',["get","population"],200]},{"id":"beijing200","type":"fill","source":"beijing","paint":{"fill-color":"#f04040"},"filter":['all',['<',["ge...
"filter":["==",["get","name"],"海淀区"]},{"id":"beijing-chaoyang","type":"fill","source":"beijing","paint":{"fill-color":"#FFCCCC"},"filter":["==",["get","name"],"朝阳区"]}...]
const testGeoJOSN = () => { // 加载 GeoJSON 数据 map.addSource("geojson", { type: "geojson", data: china, generateId: true, }); map.addLayer({ id: "china", type: "fill", source: "geojson", paint: { "fill-color": "#627BC1", "fill-opacity": [ "case", ["boolean",...
{"id":"beijing100","type":"fill","source":"beijing","paint":{"fill-color":"#ffaa7f"},"filter":['all',['<',["get","population"],100],['>=',["get","population"],50]]},{"id":"beijing50","type":"fill","source":"beijing","paint":{"fill-color":"#ffd0a6"},"...
paint: { 'fill-color': [ 'case', ['boolean', ['feature-state', 'click'], false], 'yellow', ['boolean', ['feature-state', 'hover'], false], 'red', 'blue' ], 'fill-opacity': 0.2, 'fill-outline-color': 'red' }
paint: { "fill-color": [ "case", // 通过字段name进行唯一值渲染 // 属性值为1的颜色为rgb(255,0,0),红色 ["<=", ["get","id"],2], "rgb(255,0,0)", ["<=", ["get","id"],3], "rgb(255,255,0)", // 没有被指定颜色的属性值,默认为该颜色 ...
首先,通过map对象获取到你想要重置颜色的图层的引用。可以使用map.getLayer方法,并传入图层的id来获取图层对象。 通过setLayoutProperty方法设置图层的属性。传入图层id、属性名称和新的属性值即可。在这种情况下,我们需要设置图层的"fill-color"属性。 将新的颜色值作为属性值传入setLayoutProperty方法。可以使用RGB、RGBA...
});// 添加图层map.addLayer({id:"uniquePolygon",type:"fill",source:"polygon",paint: {"fill-color": ["match",// 通过字段name进行唯一值渲染// 属性值为1的颜色为rgb(255,0,0),红色["get","name"],"1","rgb(255,0,0)","2","rgb(255,255,0)","3","rgb(0,255,0)",// 没有被...
// paint: { // 'fill-color': 'green', // 填充颜色 // 'fill-opacity': 0.3, // 透明度 // 'fill-outline-color': 'green' // 边缘颜色 // } paint: { 'circle-radius': [ // 根据像素来定义半径 'interpolate', ['linear'], ...