CartoDB / mobile-sdk

CARTO Mobile SDK core project
https://carto.com/docs/carto-engine/mobile-sdk/
BSD 3-Clause "New" or "Revised" License
184 stars 65 forks source link

cant get `setMaxOverzoomLevel` to work #503

Open farfromrefug opened 2 years ago

farfromrefug commented 2 years ago

I cant get this to work. I have a layer which datasource stops at zoom 7. Even if i set setMaxOverzoomLevel(1) (or even 0). Then at zoom (let s say) 14 it will always find the parent tile from 7. I would expect to render empty tile at zoom 14

mtehver commented 2 years ago

@farfromrefug 'Overzoom' only applies to tiles already loaded and cached. Thus is if overzoom=1 and current zoom=6 and the relevant tile is not available, SDK checks if it has zoom=5 tile cached. If it has, then this tile is displayed instead while the zoom=6 tile is being fetched.

farfromrefug commented 2 years ago

@mtehver ok i see so there is no way to say like stop rendering the data source if the we are 6 level over zoom ? The use case is hillshade where the rendering of high overzoom can be very ugly. Would be good to be able to say stop at overzoom 3. This is what i thought setMaxOverzoomLevel was for

mtehver commented 2 years ago

@farfromrefug Documentation is somewhat ambiguous here, so I can see how it caused the confusion. As the use case is quite specific, the option is to create a custom data source that returns empty tiles starting from some threshold zoom level.

farfromrefug commented 2 years ago

@mtehver great idea! i am on it!

farfromrefug commented 2 years ago

@mtehver i might need a bit of help from you on this. I started to implement this by returning std::make_shared<TileData>(std::shared_ptr<BinaryData>()); for empty tiles. Then in RasterLayer it falls into that if My issue is that going there seems to still draw what's in the cache. How can i prevent that? I have a feeling it is because the parent tile is found in the preloadingCache. Can i invalidate the tile from preloadingCache when i fail into my overzoomLevel ? EDIT: maybe the solution is to return a "transparent" tile? but i am not sure how to make it work with vector and raster tiles

mtehver commented 2 years ago

@farfromrefug Good find regarding caching and null tileData.data, I think the correct behavior would be to removing respective tile from the cache. As a workaround, creating a transparent tile should work fine.

farfromrefug commented 2 years ago

@mtehver ok i ll try removing from the cache