maplibre-gl-js
maplibre-gl-js copied to clipboard
3D terrain blocks style updates
maplibre-gl-js version: 2.4.0
browser: Firefox and Chrome
Steps to Trigger Behavior
- Create a base map with 3D terrain
- Create a button to toggle on and off an additional layer.
// Function to toggle on/off a map layer
function toggleLayer(layerName){
var checkBox = document.getElementById(layerName.concat('checkbox'));
if (checkBox.checked === true){
map.addLayer({
'id': 'mylayer',
'type': 'fill',
'source': 'mysource',
'source-layer': 'mysource',
"paint": {'fill-color': '#4d9221'}
}, 'roads 0 Restricted Road' // Sink the new layer into the base map
);
} else {
if (map.getLayer(layerName)) map.removeLayer(layerName);
}
}
This bug only appears if the additional layer is placed within the main style. If the additional layer is placed on top of the base map the bug does not occur.
3. Toggle your map layer on and off to check that it works
4. Turn on 3D terrain using the maplibregl.TerrainControl
5. Try toggling the map layer on and off - it won't work
6. Turn off 3D terrain
7. The maps will automatically update and toggling will work again.
The only clue I've found for what is going wrong is that map.getLayer(layerName) returns undefined when the 3D terrain is on.
Link to Demonstration
https://www.carbon.place/bug.html
Expected Behavior
You can toggle the data layer on and off with or without 3D terrain
Actual Behavior
With 3D terrain, you can toggle the data layer on once, but then never off again until the 3D terrain is disabled. Also, the borders of the polygons vanish when the 3D terrain is on.
Some images to show the bug
No 3D terrain layer toggles on and off fine:

Enable 3D terrain, layer toggles on but the boarders to the polygons are missing

Try to turn off the layer and it remains, unless you pan/zoom to a different area

Disable 3D terrain and everything works again.
Hello, this issue is alredy covered by https://github.com/maplibre/maplibre-gl-js/pull/1301, but it still needs some work before merging.
I think this issue should be fixed after merging https://github.com/maplibre/maplibre-gl-js/pull/1671 into main. Can you please test?
The relevant PR was merged and I think version 3 pre.1 had this in. Can you please check and close this issue if this was fixed?
The relevant PR was merged and I think version 3 pre.1 had this in. Can you please check and close this issue if this was fixed?
Version 3.0.0-pre.1 or higher fixes this issue for me.
Fixed by #1671