josxha / flutter_map_plugins

The source code for all sorts of flutter_map plugins.
https://pub.dev/publishers/joscha-eckert.de/packages
29 stars 21 forks source link

`PmTilesVectorTileProvider` doesn't shows any details of higher zoom levels #17

Closed netvandal closed 8 months ago

netvandal commented 9 months ago

Hi There, Can you give me any hint or suggestion on how to work and improve the rendering of the Map. Testing the sample app I can get it working but seems that the vector_map_tiles_pmtiles map is quite basic. Using ProvidedThemes.lightTheme() render like this:

Screenshot 2024-02-06 at 15 50 09 I have some questions: 1) is this the expected look? 2) Have you any hint on how to improve it (I'll be happy to help if you give me a starting point) 3) Can be the style.json here: https://maps.protomaps.com/#map=7.99/45.234/10.21&theme=light&renderer=maplibregl&tiles=https://build.protomaps.com/20240206.pmtiles be of any help? Thankyou very much for your work.

josxha commented 9 months ago

Hi @netvandal, thanks for bringing some attention to this.

  1. is this the expected look?

No indeed is is not. After some testing I'm still not sure what causes this bug. Since vector_map_tiles_pmtiles is more or less just the binding between vector_map_tiles and pmtiles it's likely that the bug might be hidden in one of these packages.

One important thing: The VectorTileLayer caches it's rendered tiles when using layerMode: VectorTileLayerMode.raster, which is the default. You can either use layerMode: VectorTileLayerMode.vector or disable the caches:

              VectorTileLayer(
                  theme: _style,
                  // disable cache while testing
                  fileCacheTtl: Duration.zero,
                  memoryTileCacheMaxSize: 0,
                  memoryTileDataCacheMaxSize: 0,
                  fileCacheMaximumSizeInBytes: 0,
                  textCacheMaxSize: 0,
  1. Have you any hint on how to improve it (I'll be happy to help if you give me a starting point)

Thanks, I'd glad to accept any help. vector_map_tiles supports the rendering of more details (see the example project and screenshots here). It could be that pmtiles mvt has some other format than the has some other pbf tiles that come from a tile provider like Mapbox or StadiaMaps? ...although I can only guess at the moment.

  1. Can be the style.json here:

I tried with the protomaps style.json but it didn't work either.

netvandal commented 9 months ago

Seems a "Theme" problem. Starting from this: https://github.com/greensopinion/flutter-vector-map-tiles-examples/blob/main/lib/examples/light_custom_theme.dart and from this: https://github.com/greensopinion/dart-vector-tile-renderer/blob/3930bf8b0cd31105ee80a7d5b39790644130aef2/lib/src/themes/light_theme.dart#L4

And then analyzing the tiles with this tool: https://protomaps.github.io/PMTiles/?url=https%3A%2F%2Fbuild.protomaps.com%2F20240207.pmtiles#map=0.93/0/0 I can spot some difference in the layer naming. Trying to make a custom theme seems to work (at least changing some of the style ), and I, for example, be able to display buildings . I'll try to come up with something usable.

netvandal commented 9 months ago

Bingo!

Screenshot 2024-02-07 at 15 09 47

I'll do a pull request soon :)

josxha commented 9 months ago

Well done! Looking good so far.