Giter Club home page Giter Club logo

Comments (7)

greensopinion avatar greensopinion commented on July 27, 2024 1

Felix, thanks for the issue. Have you found a solution for MBTiles? If so it would be great if you could share your approach here. I'm not sure if you meant to close this issue.

from flutter-vector-map-tiles.

goritz avatar goritz commented on July 27, 2024 1

Hi, ive had the same issue with loading offline vector tiles from a mbtiles file, and just figured out a working method which i wanted to share:

So, mbtiles are basically a sqlite database which holds the tiles as gzipped pbf blob data.
You can create your own VectorTileProvider which converts the TileIdentity xyz adress into a SQL Statement like this:
"SELECT tile_data FROM tiles WHERE zoom_level = ${tile.z} AND tile_column = ${tile.x} AND tile_row = $y"

As noted in the MBTiles spec, you have to flip the y axis like this:
int y=(pow(2,z)-1-tile.y).toInt();

Note that in the TMS tiling scheme, the Y axis is reversed from the "XYZ" coordinate system commonly used in the URLs to request individual tiles, so the tile commonly referred to as 11/327/791 is inserted as zoom_level 11, tile_column 327, and tile_row 1256, since 1256 is 2^11 - 1 - 791.

Query the mbtiles file and gzip.decode the resulting blob to get the raw pbf vector data

Keep in mind that these pbf tiles are still written to disk by the parent VectorTileProvider (like any network-based provider) and wont be used directly from memory

from flutter-vector-map-tiles.

mdmm13 avatar mdmm13 commented on July 27, 2024 1

Thank you so much @goritz for the detailed explanation, much appreciated! We will give it a try these coming weeks and contribute to the source here.

Stumbled across this repo also, where a first stab was made at this approach. Will review and revert back.

Got a feeling that this will be quite the popular feature for this plugin :-)

from flutter-vector-map-tiles.

greensopinion avatar greensopinion commented on July 27, 2024

Thanks for the issue! Sorry, but MBTiles are not supported.

It would help to understand your use-case. What do you want to achieve with MBTiles?

from flutter-vector-map-tiles.

felixjunghans avatar felixjunghans commented on July 27, 2024

We are currently using MBTiles to provide OSM maps of different regions offline for our users.

I found the following package MBTilesImageProvider. But this is only suitable for MBTiles that contain png data. However, I managed to modify the code so that it now also works with vector maps. If you like I can create a PR for the MBTilesVectorProvider.

from flutter-vector-map-tiles.

LeeviLeppala avatar LeeviLeppala commented on July 27, 2024

We are currently using MBTiles to provide OSM maps of different regions offline for our users.

I found the following package MBTilesImageProvider. But this is only suitable for MBTiles that contain png data. However, I managed to modify the code so that it now also works with vector maps. If you like I can create a PR for the MBTilesVectorProvider.

Hi @felixjunghans, would you care to shed some light on how you got vector tiles from MBtiles working?

from flutter-vector-map-tiles.

mdmm13 avatar mdmm13 commented on July 27, 2024

Hi @felixjunghans - like Leevi, we're also looking into figuring out offline storage for map segments, either via MBTILES or MVT. Which way did you end up going with your offline vector tile solution?

from flutter-vector-map-tiles.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.