Leaflet / Leaflet.VectorGrid

Display gridded vector data (sliced GeoJSON or protobuf vector tiles) in Leaflet 1.0.0
600 stars 194 forks source link

Load .mbtiles #54

Open glandais opened 7 years ago

glandais commented 7 years ago

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

glandais commented 7 years ago

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 commented 7 years ago

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:

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 commented 6 years ago

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 commented 6 years ago

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