maplibre-gl-js icon indicating copy to clipboard operation
maplibre-gl-js copied to clipboard

3D terrain blocks style updates

Open mem48 opened this issue 3 years ago • 2 comments

maplibre-gl-js version: 2.4.0

browser: Firefox and Chrome

Steps to Trigger Behavior

  1. Create a base map with 3D terrain
  2. 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.

mem48 avatar Sep 07 '22 22:09 mem48

Some images to show the bug

No 3D terrain layer toggles on and off fine:

image

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

image

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

Disable 3D terrain and everything works again.

mem48 avatar Sep 07 '22 22:09 mem48

Hello, this issue is alredy covered by https://github.com/maplibre/maplibre-gl-js/pull/1301, but it still needs some work before merging.

prozessor13 avatar Sep 08 '22 07:09 prozessor13

I think this issue should be fixed after merging https://github.com/maplibre/maplibre-gl-js/pull/1671 into main. Can you please test?

prozessor13 avatar Oct 07 '22 08:10 prozessor13

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?

HarelM avatar Oct 21 '22 19:10 HarelM

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.

boeckMt avatar Jan 23 '23 14:01 boeckMt

Fixed by #1671

HarelM avatar Jan 23 '23 16:01 HarelM