Open tillda opened 1 month ago
If you are using pmtiles serve
to decode on the server you don't need to use new pmtiles.PMTiles
at all, which is for client-side decoding. Access your tiles via /{z}/{x}/{y}
URLs.
Thanks for a prompt reply. I quicky tried the example in your CodePen. No matter what url i put in url:
below, I always get one of these 404s. Also, can't there be some bug with those %2F
s? Surprisingly. http://localhost:8080/myaustria/metadata
DOES return correct JSON response.
2024/06/22 15:53:12 main.go:147: served 404 %2Fmyaustria.pmtiles in 98.708µs
2024/06/22 15:53:30 main.go:147: served 404 %2Fmyaustria in 18.125µs
App.js:
<Map
style={{ width: 600, height: 400 }}
mapStyle={{
version: 8,
sources: {
sample: {
type: "vector",
url:
"pmtiles://http://localhost:8080/myaustria.pmtiles"
}
},
mapStyle={{
version: 8,
sources: {
sample: {
type: "vector",
url:
"pmtiles://http://localhost:8080/myaustria.pmtiles"
}
},
Again, you do not need pmtiles://
for client-side decoding if you are using pmtiles serve
on the server side. Please see these docs: https://maplibre.org/maplibre-style-spec/sources/#vector
I was having a seemingly identical issue, for reference I am basing my code on the MapLibre PMTiles example and running the docker go-pmtiles container to serve my .pmtiles file.
I solved the issue by changing the "url" to "tiles" reference, see the *** section in your adjusted code below.
<Map
style={{ width: 600, height: 400 }}
mapStyle={{
version: 8,
sources: {
sample: {
type: "vector",
***
tiles: [
"http://localhost:8080/myaustria/{z}/{x}/{y}.mvt"
]
***
}
},
This is what @bdon mentioned above, I'm just adding the example code as I missed the "url" -> "tiles" at the start when working on it myself. Hope this helps.
@GridGrapher thanks for posting the example, I updated the JS code here with a comment:
https://github.com/protomaps/PMTiles/pull/417/files
If you are using go-pmtiles
you don't need to pay attention to any of the client-side PMTiles code at all, you can just access it from MapLibre like any typical ZXY URL the way most of the MapLibre documentation shows.
Where it can get confusing is url
and tiles
: https://maplibre.org/maplibre-style-spec/sources/
tiles
is a array of ZXY endpoints, because historically many APIs had multiple mirrors under different subdomains to improve performanceurl
usually loads a TileJSON https://github.com/mapbox/tilejson-spec endpoint. This has a few advantages over using a ZXY url, it pre-populates the min/maxzoom. You can access TileJSON from go-pmtiles at http://localhost:8080/myaustria.json
but it requires setting the public url initialization variable to generate proper URLs.
I have a
tiles
directory withmyeurope.mbtiles
. From which I run all sorts ofpmtiles serve .
variants. I am trying the MapLibre example. No matter what I try I always get a 404 response. I actually also don't understand if the URL that goes tonew pmtiles.PMTiles
should be"http://localhost:8080/myaustria"
or"http://localhost:8080/myaustria.pmtiles"
I Aways get 404 response(s) like this:
The 204 is "No Content" status code.