opensciencemap / vtm

a vector-tile map library written in java - running on android, desktop and within the browser
GNU Lesser General Public License v3.0
238 stars 176 forks source link

Map base layer vs many maps on the screen #140

Open AAverin opened 9 years ago

AAverin commented 9 years ago

At the moment Map class requires a map base layer to be set via setBaseMap. That map layer seems to be very important, because map theme is applied to that layer specifically.

Now, imagine that situation where you have many maps on the screen. Base map is set to some rough approximation, and other maps are added as VectorTileLayer's on top. The base map being an approximation needs to be removed at some point when we have a higher level of detalization available on another layer.

Right now removing base map breaks the rendering of other layer completely.

Is there a workround? And a general question - any difference between base map and any other tile layer? Why is it so special?

AAverin commented 9 years ago

Ok, a little update to the issue. If I remove any layer while it's visible on the screen - map rendering just dies. All that was on the screen at that point keeps displaying, but other tiles no longer show up and load.

The main idea here is to be able to do 2 things:

  1. Ability to hide some layers, make them invisible - that is needed for better coastline detalization, for example
  2. Completely remove some layers that are not required at the moment. That is needed for the case when many layers are added on the map, and some are not visible at the moment, but still consume memory with loaded tiles. It might be better to unload them from memory for low-spec devices on demand.
AAverin commented 9 years ago

Latest investigations bring me to this line of VectorTileRenderer if (buckets == null || buckets.vbo == null) { //log.debug("{} no buckets!", tile); return; }

So, what I get after I suddenly remove a large visible layer from the screen - some of the tiles stop drawing, and tiles of the next zoom level also no longer display. Rendering quits on buckets.vbo being null.

AAverin commented 9 years ago

To resolve the issue I had to completely reload all other tile layers on screen. This is a workaround, but not a solution, I think.

bmarchionni commented 9 years ago

Any other update on this? I just discovered that if I remove a layer all other layers stop drawing properly.

Another option would be to simply have a way to turn layers on/off instead of removing them but I haven't found any way to do this.

AAverin commented 9 years ago

For now I managed the problem by re-loading layers. Some times you even have to force layers refresh by re-loading them for map to start rendering properly. Disabling layers is fine idea and it will help in lots of cases. But the drawback would be that hidden layer would still occupy memory, and in some cases you would want to completely remove layer and all it contents from the map.

bmarchionni commented 9 years ago

How do you reload the layers?