felt / tippecanoe

Build vector tilesets from large collections of GeoJSON features.
BSD 2-Clause "Simplified" License
874 stars 76 forks source link

MBTiles and PBF Directory Outputs not rendering in the web #204

Open jdcarls2 opened 5 months ago

jdcarls2 commented 5 months ago

I have a pretty standard process.

  1. Generate vector tiles with tippecanoe
tippecanoe -l contours -f -y ELEV -pn -zg -e contours contours.geojson
  1. Create a basic MapLibre map
  2. Open map and look at results

When my output is a PMTiles file, it loads fine. When output to MBTiles or a directory of PBF files, nothing renders in the map. In Firefox, I see messages like these:

Error: Unable to parse the tile at https://localhost/contours-2018/11/521/762.pbf, please make sure the data is not gzipped and that you have configured the relevant header in the server.

Here's one of the tiles, if you want to see it. The file opens in Q just fine.

morandd commented 5 months ago

This is a common problem, and I think the cause is that the PBF files from tippecanoe are normally GZipped, and but your web server does not add the "content-type: application/gzip" header which means the browser does not unzip them, so the javascript mapping library is trying to read a .gz byte stream instead of a PBF byte stream. Either don't use the zip option in tippecanoe, or else add the "content type' header when you serve the files.