layerchart 0.41.2 → 0.41.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
2
|
import { tile as d3Tile } from 'd3-tile';
|
|
3
3
|
import { geoContext } from './GeoContext.svelte';
|
|
4
|
+
import Group from './Group.svelte';
|
|
4
5
|
import TileImage from './TileImage.svelte';
|
|
5
6
|
export let url;
|
|
6
7
|
export let zoomDelta = 0;
|
|
7
8
|
export let tileSize = 256;
|
|
8
9
|
export let disableCache = false;
|
|
9
10
|
export let debug = false;
|
|
10
|
-
const {
|
|
11
|
+
const { containerWidth, containerHeight, padding } = getContext('LayerCake');
|
|
11
12
|
const canvas = getContext('canvas');
|
|
12
13
|
const geo = geoContext();
|
|
14
|
+
$: center = $geo([0, 0]) ?? [0, 0];
|
|
13
15
|
$: tile = d3Tile()
|
|
14
|
-
.size([$
|
|
16
|
+
.size([$containerWidth, $containerHeight])
|
|
17
|
+
.translate([center[0] + $padding.left, center[1] + $padding.top])
|
|
15
18
|
.scale($geo.scale() * 2 * Math.PI)
|
|
16
|
-
.translate($geo([0, 0]) ?? [0, 0]) // TODO: Only works with Mercator
|
|
17
19
|
.tileSize(tileSize)
|
|
18
20
|
.zoomDelta(zoomDelta);
|
|
19
21
|
$: tiles = tile();
|
|
@@ -38,8 +40,10 @@ $: if (renderContext === 'canvas' && $ctx && url) {
|
|
|
38
40
|
|
|
39
41
|
{#if renderContext === 'svg' && url}
|
|
40
42
|
<slot {tiles}>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
<Group x={-$padding.left} y={-$padding.top}>
|
|
44
|
+
{#each tiles as [x, y, z] (url(x, y, z))}
|
|
45
|
+
<TileImage {url} {x} {y} {z} {tx} {ty} {k} {disableCache} {debug} />
|
|
46
|
+
{/each}
|
|
47
|
+
</Group>
|
|
44
48
|
</slot>
|
|
45
49
|
{/if}
|