protomaps / PMTiles

Cloud-optimized + compressed single-file tile archives for vector and raster maps
https://protomaps.com/docs/pmtiles/
BSD 3-Clause "New" or "Revised" License
2.02k stars 118 forks source link

Unable to display map on browsers #30

Closed xinyuluo closed 2 years ago

xinyuluo commented 2 years ago

Hi! I'm new to this project. I tried running some html files in the example section in Safari/Chrome but maps were not shown. I got the following errors: image I couldn't figure out why fetch is aborted. Is there something I'm missing here?

Thank you.

bdon commented 2 years ago

how are you serving the directory containing the PMTiles? using the file:/// protocol won't work, you need to use an HTTP server like the nodejs http-server or this small go program I've included: https://github.com/protomaps/PMTiles/blob/master/examples/serve_localhost.go

xinyuluo commented 2 years ago

Hi Brandon, thanks for your quick reply.

I was previously using python -m http.server but once I switched to nodejs http-server it works :)

xinyuluo commented 2 years ago

However, If I replace the pmtiles file from the example to one I generated using pmtiles-convert (converting from mbtiles file), I cannot display tiles on the web properly. For Leaflet, I get an error image like this: image

and for maplibre gl I don't see anything in the interface. Do you know what might be the cause of it? Thank you.

bdon commented 2 years ago

@xinyuluo you are using vector tiles (uncompressed) as the tile format inside the PMTiles? what console errors do you get? can you share your HTML code and datasets via GitHub gist?

xinyuluo commented 2 years ago

@bdon yes I used vector tiles; should I use raster tiles instead? I didn't get any console errors. For my HTML code, i used almost the same code from the example (just replacing tile file and coordinates): https://gist.github.com/xinyuluo/aea1b52d7ddbb33d8722ca6acde9bc51. I'm not sure how to share tile datasets via gist, so they are here: https://drive.google.com/drive/folders/1yutH5rn4Q5ZuvZlo0Eb_xRAFPQRWxc0U?usp=sharing. Thank you!

bdon commented 2 years ago

Hi Xinyu,

Everything is working correctly - you can verify the PMTiles archive by dropping it into the inspector here: https://protomaps.github.io/PMTiles/examples/inspector.html

What's happening is that the style you have defined does not visualize any of the layers in the vector tiles: the examples I show are based off the layers and tags defined here: https://protomaps.com/docs/map-layers-tags/ while your PMTiles uses the OpenMapTiles schema. You'll need to replace the style with one designed against the OpenMapTiles schema or make some changes to the example styles: like, replace road with transportation and building with buildings for source-layer

xinyuluo commented 2 years ago

Hi Brandon, it works! Thank you for your tips. :)