0

I'm new to the offline mapping world and have been trying to work out how to load a .mbtiles file into Leaflet, and it seems that because they're PBF (or maybe I'm lost there), it's not working. I was able to find a .mbtiles file that was a raster, and it loaded fine, but any time I try to load one of the other files (like one downloaded from tilea.io), it fails and I get a tilerror.

Here's the snippet im using, this file works, but if I change to another mbtiles file, it throws an error. I'll add the error below the code

      // when i change the file to another mbtiles file, it breaks,
//but this one works fine as its a raster i assume?
    const coloradoTile = await fetch(
      new URL("./countries-raster.mbtiles", import.meta.url)
    );
    const coloradoBlob = await coloradoTile.blob();
    const coloradoURL = URL.createObjectURL(coloradoBlob);


    const mbtilesLayer = L.tileLayer
      .mbTiles(coloradoURL, {
        minZoom: 0,
        maxZoom: 30,
        tms: true,
        attribution:
          'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors',
      })
      .addTo(map);

Heres the errors i get:

enter image description here

4
  • 1
    Could you add the working code for the raster and the error to help people answer your question?
    – Fee
    Commented Aug 31 at 2:39
  • 1
    @Fee Done, not sure if itll help but thats what I have and what im getting. Commented Aug 31 at 6:20
  • Can you provide access to the .mbtiles file that is not working for you?
    – TomazicM
    Commented Aug 31 at 9:30
  • 1
    error in text? from this screenshot it is not possible to see the entire error, which would be my first thing to scour through when debugging.
    – Fee
    Commented Aug 31 at 12:04

1 Answer 1

0

I actually ended up going a little bit different of a route and creating my own mbtiles file as a raster and it works now. It was something with the vector tiles or something. So for now, this can be considered as resolved as it solves my use case.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.