mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 10:51:07 +00:00
allow status code 200 for gh pages
This commit is contained in:
@@ -18,7 +18,7 @@
|
|||||||
<div id="map"></div>
|
<div id="map"></div>
|
||||||
<script>
|
<script>
|
||||||
const map = L.map('map',{maxZoom:4}).setView([0,0],0)
|
const map = L.map('map',{maxZoom:4}).setView([0,0],0)
|
||||||
const p = new pmtiles.PMTiles('osm_carto.pmtiles')
|
const p = new pmtiles.PMTiles('osm_carto.pmtiles',{allow_200:true})
|
||||||
p.leafletLayer({attribution:'© <a href="https://openstreetmap.org">OpenStreetMap</a> contributors'}).addTo(map)
|
p.leafletLayer({attribution:'© <a href="https://openstreetmap.org">OpenStreetMap</a> contributors'}).addTo(map)
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -40,10 +40,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
class PMTiles {
|
class PMTiles {
|
||||||
constructor(url) {
|
constructor(url, options) {
|
||||||
this.url = url
|
this.url = url
|
||||||
this.root = fetch(this.url,{method:'HEAD',headers:{Range:'bytes=0-511999'}}).then(resp => {
|
this.root = fetch(this.url,{method:'HEAD',headers:{Range:'bytes=0-511999'}}).then(resp => {
|
||||||
if (resp.status == 206) { // this does not work on Azure, it returns 200 instead of 206
|
// for servers like Azure, GH Pages which return 200 instead of 206
|
||||||
|
if (resp.status == 206 || (resp.status == 200 && options.allow_200)) {
|
||||||
console.log("Check succeeded: server supports byte ranges")
|
console.log("Check succeeded: server supports byte ranges")
|
||||||
return fetch(this.url,{headers:{Range:'bytes=0-511999'}}).then(resp => {
|
return fetch(this.url,{headers:{Range:'bytes=0-511999'}}).then(resp => {
|
||||||
return resp.arrayBuffer()
|
return resp.arrayBuffer()
|
||||||
|
|||||||
Reference in New Issue
Block a user