mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 10:51:07 +00:00
fix binding this in ProtocolCache; update maplibre examples
This commit is contained in:
@@ -18,7 +18,8 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="map"></div>
|
<div id="map"></div>
|
||||||
<script>
|
<script>
|
||||||
pmtiles.addProtocol(maplibregl)
|
let cache = new pmtiles.ProtocolCache();
|
||||||
|
maplibregl.addProtocol("pmtiles",cache.protocol);
|
||||||
var style = {
|
var style = {
|
||||||
"version": 8,
|
"version": 8,
|
||||||
"sources": {
|
"sources": {
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ tippecanoe -zg --projection=EPSG:4326 --no-tile-compression --no-feature-limit -
|
|||||||
pmtiles-convert cb_2018_us_zcta510_500k_nolimit.mbtiles cb_2018_us_zcta510_500k_nolimit.pmtiles</pre>
|
pmtiles-convert cb_2018_us_zcta510_500k_nolimit.mbtiles cb_2018_us_zcta510_500k_nolimit.pmtiles</pre>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
pmtiles.addProtocol(maplibregl)
|
let cache = new pmtiles.ProtocolCache();
|
||||||
|
maplibregl.addProtocol("pmtiles",cache.protocol);
|
||||||
var style = {
|
var style = {
|
||||||
"version": 8,
|
"version": 8,
|
||||||
"sources": {
|
"sources": {
|
||||||
|
|||||||
@@ -451,7 +451,7 @@ export class ProtocolCache {
|
|||||||
return this.tiles.get(url);
|
return this.tiles.get(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
protocol(params: any, callback: any) {
|
protocol = (params: any, callback: any) => {
|
||||||
const re = new RegExp(/pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)/);
|
const re = new RegExp(/pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)/);
|
||||||
const result = params.url.match(re);
|
const result = params.url.match(re);
|
||||||
const pmtiles_url = result[1];
|
const pmtiles_url = result[1];
|
||||||
@@ -495,5 +495,5 @@ export class ProtocolCache {
|
|||||||
cancel();
|
cancel();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user