Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Reading offline maps from MBTiles #103

Closed
DenisCarriere opened this issue Aug 17, 2017 · 1 comment
Closed

Reading offline maps from MBTiles #103

DenisCarriere opened this issue Aug 17, 2017 · 1 comment

Comments

@DenisCarriere
Copy link

DenisCarriere commented Aug 17, 2017

Just wanted to say this is an amazing initiative! Keep up the great work! 👍

Was wondering if reading MBTiles instead of a Tile Servers would be beneficial for your application.

I've created a NodeJS MBTiles binding which I'm currently using in an Electron app, I'm using Leaflet and I've written a custom wrapper to Leaflet to read map tiles directly from the file system instead of reading them from a HTTP connection (local tile server).

Library which you will need:

If you need any help implementing this, let me know!

Snippet to extend Leaflet to read MBTiles

Extending the createTile method in the Leaflet TileLayer Class

this.mbtiles.findOne([coords.x, coords.y, coords.z]).then(image => {
  if (!image) tile.src = L.Util.emptyImageUrl
  tile.src = window.URL.createObjectURL(new Blob([new Uint8Array(image)], {type: 'image/png'}))
  L.DomEvent.on(tile, 'load', Util.bind(this._tileOnLoad, this, done, tile))
  L.DomEvent.on(tile, 'error', Util.bind(this._tileOnError, this, done, tile))
})
@okdistribute
Copy link
Contributor

Hi thanks for opening this @DenisCarriere!

Just to note, we are looking at this in the upcoming development cycle (~winter)

If you're still available to help implement this we'd be open to a pull request.

@digidem digidem locked and limited conversation to collaborators Oct 1, 2021
@ErikSin ErikSin closed this as completed Oct 1, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants