mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 10:51:07 +00:00
remove headers option
This commit is contained in:
@@ -40,13 +40,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
class PMTiles {
|
class PMTiles {
|
||||||
constructor(url,headers={},ready) {
|
constructor(url,ready) {
|
||||||
headers.Range = 'bytes=0-511999'
|
|
||||||
this.url = url
|
this.url = url
|
||||||
this.rootdir = fetch(this.url,{method:'HEAD',headers:headers}).then(resp => {
|
this.rootdir = 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
|
if (resp.status == 206) { // this does not work on Azure, it returns 200 instead of 206
|
||||||
console.log("Check succeeded: server supports byte ranges")
|
console.log("Check succeeded: server supports byte ranges")
|
||||||
return fetch(this.url,{headers:headers}).then(resp => {
|
return fetch(this.url,{headers:{Range:'bytes=0-511999'}}).then(resp => {
|
||||||
return resp.arrayBuffer()
|
return resp.arrayBuffer()
|
||||||
}).then(buf => {
|
}).then(buf => {
|
||||||
const header = parseHeader(new DataView(buf,0,10))
|
const header = parseHeader(new DataView(buf,0,10))
|
||||||
@@ -74,7 +73,7 @@
|
|||||||
this.outstanding_requests.get(offset).push(resolve)
|
this.outstanding_requests.get(offset).push(resolve)
|
||||||
} else {
|
} else {
|
||||||
this.outstanding_requests.set(offset,[])
|
this.outstanding_requests.set(offset,[])
|
||||||
fetch(this.url, {headers:{'range':'bytes=' + offset + '-' + (offset + len-1)}}).then(resp => {
|
fetch(this.url, {headers:{Range:'bytes=' + offset + '-' + (offset + len-1)}}).then(resp => {
|
||||||
return resp.arrayBuffer()
|
return resp.arrayBuffer()
|
||||||
}).then(buf => {
|
}).then(buf => {
|
||||||
var map = bytesToMap(new DataView(buf),len/17)
|
var map = bytesToMap(new DataView(buf),len/17)
|
||||||
@@ -146,7 +145,7 @@
|
|||||||
|
|
||||||
self.getZxy(coord.z,coord.x,coord.y).then(result => {
|
self.getZxy(coord.z,coord.x,coord.y).then(result => {
|
||||||
if (result === null) return
|
if (result === null) return
|
||||||
fetch(self.url,{headers:{'Range':'bytes=' + result[0] + '-' + (result[0]+result[1]-1)}}).then(resp => {
|
fetch(self.url,{headers:{Range:'bytes=' + result[0] + '-' + (result[0]+result[1]-1)}}).then(resp => {
|
||||||
return resp.arrayBuffer()
|
return resp.arrayBuffer()
|
||||||
}).then(buf => {
|
}).then(buf => {
|
||||||
var blob = new Blob( [buf], { type: "image/png" } )
|
var blob = new Blob( [buf], { type: "image/png" } )
|
||||||
|
|||||||
Reference in New Issue
Block a user