mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 02:41:09 +00:00
implement cancellation for maplibre fetch [#1]
This commit is contained in:
@@ -206,18 +206,22 @@ export const addProtocol = maplibre_instance => {
|
||||
let z = result[2]
|
||||
let x = result[3]
|
||||
let y = result[4]
|
||||
var cancel = () => {}
|
||||
instance.getZxy(+z,+x,+y).then(val => {
|
||||
if (val) {
|
||||
let headers = {'Range':'bytes=' + val[0] + '-' + (val[0]+val[1]-1)}
|
||||
fetch(pmtiles_url,{headers:headers}).then(resp => {
|
||||
const controller = new AbortController()
|
||||
const signal = controller.signal
|
||||
fetch(pmtiles_url,{signal:signal,headers:headers}).then(resp => {
|
||||
return resp.arrayBuffer()
|
||||
}).then(arr => {
|
||||
callback(null,arr,null,null)
|
||||
})
|
||||
cancel = controller.abort
|
||||
} else {
|
||||
callback(null,new Uint8Array(),null,null)
|
||||
}
|
||||
})
|
||||
return { cancel: () => { console.log("Cancel not implemented") } }
|
||||
return { cancel: cancel }
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user