-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Update minZoom check to ignore zoomOffset and rounding #9807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Bear in mind that this would be a breaking change as apps would load different tiles for the same viewport. So this is not a change we would want to make lightly. I didn't write the original code, but I believe the zoom rounding done in a way as to match what the basemap libraries are doing. Would you be able to update your table to show which level of tiles the maplibre and Google basemaps are loading in those scenarios? As loading new tiles always leads to some features "popping in", it makes sense that deck does it at the same point as the basemap to reduce the noise |
|
@felixpalmer You're right.. that is how Google Map Tiles work in Deck.GL... 9.5 zoom fetches Z=10 tiles when running this example code locally https://deck.gl/examples/google-maps: Unfortunately (or fortunately if you like things to mean what they should), that is not how MapBoxGL works. As you can see here: I guess we need some way of changing this behaviour based on what you're using as your map container? I'm assuming this is actually a MapLibreGL vs MapBoxGL thing and not really a Google Tiles vs MapBox Tiles issue. Maybe we can add a way for you to modify this behaviour in the layer properties, or automatically when using MapboxOverlay? I'll take a stab at implementing whatever you think is the best approach |
|
I agree the current behavior is confusing, though the rounding logic is a specific one that took us several iterations to reach. I think we can improve the behavior without making a breaking change:
|
|
@Pessimistress If I'm understanding your comment correctly, you're proposing this:
or in other words: "use minZoom to mean minZoom, but match MapLibre Z level calculations for which tile to grab" I think that makes sense for MapLibre, but it still creates the problem in MapboxGL where if you're passed the minZoom issue, you're still 0.5 out of sync because zoom 13.5 will grab basemap tile 13 and TileLayer tile 14. I don't think there's any way to make the logic work for both map hosts without having some logic switch. The easiest non-breaking change would likely be to add this: // I'm adding Deck.Gl and MapLibre in here just to be less confusing to someone looking at this
// when they are using MapLibre or Deck.GL and don't realize they're basically the same thing
export type TileIndexSystem = 'Deck.GL' | 'MapLibre' | 'Mapbox';
export type TileLayerOptions = {
...
tileIndexSystem: TileIndexSystem;
}
export function getTileIndices({
...
tileIndexSystem = 'Deck.GL'
}: {
...
tileIndexSystem: TileIndexSystem;
}) {
if(tileIndexSystem === 'Mapbox') {
// Do the logic originally proposed in this PR
} else {
// Do the existing logic, or also add the minZoom vs fetch difference proposed by Pessimistress
}
}We'd then need to update the documentation to explain what this does and why it's necessary. Thoughts? |
|
Agree with @Pessimistress. @rory-orennia regarding The visibility test is then improved to directly compare For the level to load, we keep the current behavior (i.e. GMaps style). I don't think it is a good idea to change the tiling loading behavior based on the basemap behavior as it will be confusing for a developer to change the basemap and have different data load. |
|
@felixpalmer I don't think this is an issue with changing basemap, it's an issue if you use MapboxOverlay with Mapbox Standard vs the built in map host. So I don't see this as an issue where a user flips a toggle to select a different basemap and now the loading behaviour is different. I'm guessing 99.99% of the apps out there have a single map host, and then some of them have the ability to use other base map styles inside that single host. I don't really see why someone would build an app that had the options of "Use Mapbox" vs "Use MapLibre" vs "Use Carto" other than a demo or POC app. Without some toggle to this logic, how would you ever make this hypothetical app work:
The minzoom fix (don't load any TileLayer until zoom is >= minzoom) fixes the most egregious error in my use case, but I'll likely have to fork or pnpm patch this project to make it line up with Mapbox Standard if I want it to be perfectly in sync (like it is for MapLibre right now) for some of our data sets. |
|
CARTO literally has a UI control that let's users switch between basemaps, including different providers. But I totally see you have a valid use-case and it would be a shame if you had to resort to forking over something like this Perhaps a way out would be to allow Math.floor(viewport.zoom + Math.log2(TILE_SIZE / tileSize)) + zoomOffsetand any other using |
|
It's not a basemap issue, it's a map host issue. If you're injecting Deck.GL into MapboxGL JS vs using Deck.GL on it's own, you get different tile fetching based on your zoom level. Doesn't matter if those tiles come from Mapbox or OpenMapTiles or Carto. Being able to zoomOffset by 0.5 would definitely fix the issue, as long as the new code for minZoom ignores that offset. So if Say we set zoomOffset to 1.5 and minZoom to 10, which of these would be what we want?
It feels a little weird that you can't ever fetch Z=10 tiles in the 'ignores' case. But I can see the logic of that as "don't show me tiles until my |
|
It feels like minZoom ignores offset is the better option - it is consistent with how the props are described in the docs.
I think this is fine, as the user has to explicitly set the prop. In general the mental model should be that:
Note this is assuming the suggestion above is implemented |
|
@felixpalmer Yeah I agree with you. I'll update this PR code and title to reflect the changes we've settled on and then your team can give it a review |
|
The new code has been pushed. It makes the following changes:
|




This fixes an issue where minZoom isn't actually minZoom because we round or ceil the current zoom. So you get scenarios like this:
After this PR:
Closes #9806
Change List