Skip to content
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

Load .mbtiles #54

Open
glandais opened this issue Jan 4, 2017 · 4 comments
Open

Load .mbtiles #54

glandais opened this issue Jan 4, 2017 · 4 comments

Comments

@glandais
Copy link

glandais commented Jan 4, 2017

How Leaflet.TileLayer.MBTiles could be merged in a Leaflet.VectorGrid.MBTiles?
Should it be a new project?
Any opinion @IvanSanchez ?

@glandais
Copy link
Author

glandais commented Jan 4, 2017

Here is my code for reading a pbf tile from a mbtiles file (ugly Python code, without using -y property)

def _get(z, x, y):
    db = get_db()
    if db is None:
        return None
    c = db.cursor()
    y2 = (1 << int(z)) - 1 - int(y)
    c.execute(
        "select tile_data from tiles where zoom_level = %s and tile_column = %s and tile_row = %s" %
        (str(z), str(x), str(y2)))
    row = c.fetchone()
    if not row:
        return None
    content = BytesIO(row[0])
    g = gzip.GzipFile(fileobj=content)
    return g.read()

@IvanSanchez
Copy link
Member

It would be interesting to try on some of the https://openmaptiles.org/downloads/#city extracts, as they are small enough for a browser to load. This is a certain possibility.

Things to check:

  • What data structure does the Leaflet.TileLayer.MBTiles get when running this._stmt.getAsObject(coords). Is this a Buffer, a base64-encoded string, something else?
  • Does this need a Pbf reader and a new VectorTile instantiation, like the VectorGrid.Protobuf code?

With those answered, it should be really simple to implement a VectorGrid.MBTiles. I would say that the code can live in this repo.

@petrot
Copy link

petrot commented Mar 13, 2018

Hey guys, is there any info about this issue? I'm looking for a sample code for using offline vector data in leaflet (mbtiles or pbf).

@AbelVM
Copy link

AbelVM commented Apr 9, 2018

this._stmt.getAsObject(coords) = {tile_data: Uint8Array}

I've playing with this merging, and as of today I have Leaflet.TileLayer.MBTiles providing pbf data as blob, but I can't find any way to easily feed the VectorGrid, as it looks for actual files to read.

But... I'm on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants