I have map that shows polygon for some regions. It works fine, but I need to add color for the whole map and make polygon transparent … like the entire map is disabled but polygon is available.
I tried to add base layer
const baseLayer = {
id: "base",
type: "background",
paint: {
"background-color": "#98b",
"background-opacity": 0.3,
},
};
// Layer for the transparent polygon
const polygonLayer = {
id: "selected",
type: "fill",
source: "selected",
layout: {},
paint: {
"fill-color": "#98b",
"fill-opacity": 0.0,
"fill-outline-color": "#000",
},
};
return (
<Map
ref={mapRef}
...
>
<Layer {...baseLayer}/>
{geojson && (
<Source id="selected" type="geojson" data={geojson}>
<Layer {...polygonLayer} />
</Source>
)}
...
</Map>
);
But the problem is that nothing happens, only if I change polygonLayer
opacity "fill-opacity": 0.2
or higher I can see the polygon because the color “stronger”, but I need transparent part.
Any idea how to make it works?