File tree 1 file changed +38
-3
lines changed
src/lib/maplibre/ext/pmtiles
1 file changed +38
-3
lines changed Original file line number Diff line number Diff line change 1
1
<script lang =" ts" >
2
2
import { Protocol as MapLibreProtocol } from ' svelte-maplibre-gl' ;
3
- import { Protocol } from ' pmtiles' ;
3
+ import { Protocol , PMTiles } from ' pmtiles' ;
4
4
5
- let { scheme = ' pmtiles' }: { scheme? : string } = $props ();
6
- const protocol = new Protocol ();
5
+ let {
6
+ scheme = ' pmtiles' ,
7
+ metadata = false ,
8
+ errorOnMissingTile = false ,
9
+ pmtiles
10
+ }: {
11
+ /** URL scheme for the PMTilesProtocol */
12
+ scheme? : string ;
13
+ /** Also load the metadata section of the PMTiles. required for some "inspect" functionality
14
+ * and to automatically populate the map attribution. Requires an extra HTTP request.
15
+ */
16
+ metadata? : boolean ;
17
+ /** When a vector MVT tile is missing from the archive, raise an error instead of
18
+ * returning the empty array. Not recommended. This is only to reproduce the behavior of ZXY tile APIs
19
+ * which some applications depend on when overzooming. */
20
+ errorOnMissingTile? : boolean ;
21
+ /** Array of PMTiles instances */
22
+ pmtiles? : PMTiles [];
23
+ } = $props ();
24
+
25
+ const protocol = new Protocol ({ metadata , errorOnMissingTile });
26
+
27
+ $effect (() => {
28
+ protocol .metadata = metadata ;
29
+ });
30
+
31
+ $effect (() => {
32
+ protocol .errorOnMissingTile = errorOnMissingTile ;
33
+ });
34
+
35
+ $effect (() => {
36
+ if (pmtiles ) {
37
+ for (const pmtile of pmtiles ) {
38
+ protocol .add (pmtile );
39
+ }
40
+ }
41
+ });
7
42
</script >
8
43
9
44
<MapLibreProtocol {scheme } loadFn ={protocol .tile } />
You can’t perform that action at this time.
0 commit comments