-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Layer setMinZoom and l.setMaxZoom not working after 5.5.x? #11386
Comments
EDIT: It DOES disable SOME of the layers but not ALL, as I was expecting. Looks like there are some "default" layers that are not disabled this way.. I'd expect a completely BLANK map outside that range. I'll keep testing but if I'm missing something please let me know. |
OK I think I understand what's happening. I have loaded the map with a json file
which works fine but once I disable all layers it seem to revert to the default map zoom levels instead of disabling the layer altogether. Is this intentional? I'd like to have the possibility of controlling the zoom levels entirely in the app instead of in the json |
Unfortunately, with #8929 We should remove |
I think that's a misunderstanding. Internally, gl-core uses immutable objects, but the public API is still mutable. There is no reason to remove |
..I'm confused. So is it mutable or not? if I can call setMinZoom on a layer I'd expect it to do something otherwise indeed it should be removed. Any workaround for this? I think being able to programmatically alter min/max zooms can be very important in some cases. |
It's a bug if |
good to see this reopened then! Thanks |
Thanks for clearing this up @jfirebaugh. After testing it out a bit more it seems like in order to enforce new min/max zoom levels we need to re-add the
|
No, expected behavior is that the new zoom level takes effect immediately, and the layer is hidden if the current zoom is outside the range, or shown if inside. It may be that all that's needed to fix this is to add mapbox-gl-native/src/mbgl/style/layers/layer.cpp.ejs Lines 107 to 117 in 82de856
And then regenerate the style code. |
Landed with #11399. |
Hi This code was working fine e.g. for limiting a bunch of layers between 2 zooms in version 5.1.x
for (Layer l : MAP.getLayers()) { l.setMinZoom(5); l.setMaxZoom(8); Log(String.format("&&LAYER %s\t%s\tzoom=(%f, %f)", l.toString(), l.getId(), l.getMinZoom(), l.getMaxZoom())); }
or
for (Layer l : MAP.getLayers()) { MAP.getLayer(l.getId()).setMaxZoom(8); MAP.getLayer(l.getId()).setMinZoom(SATELLITE_MAP_MAX_ZOOM); Log(String.format("&*&LAYER %s\t%s\tzoom=(%f, %f)", l.toString(), l.getId(), l.getMinZoom(), l.getMaxZoom())); }
..but in 5.5.x and 6.x it does nothing. Any ideas?
I'd expect ALL layers to disappear over lvl8 and under lvl5 or am I missing something?
The text was updated successfully, but these errors were encountered: