Open glandais opened 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()
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:
Leaflet.TileLayer.MBTiles
get when running this._stmt.getAsObject(coords)
. Is this a Buffer
, a base64-encoded string, something else?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.
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).
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
How Leaflet.TileLayer.MBTiles could be merged in a Leaflet.VectorGrid.MBTiles? Should it be a new project? Any opinion @IvanSanchez ?