@versatiles/svelte 2.0.1 → 2.1.0
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.
- package/dist/components/BBoxMap/BBoxMap.svelte +23 -12
- package/dist/components/BBoxMap/lib/bbox.d.ts +1 -1
- package/dist/components/BBoxMap/lib/bbox.js +19 -17
- package/dist/components/BasicMap/BasicMap.svelte +22 -9
- package/dist/components/BasicMap/BasicMap.svelte.d.ts +2 -1
- package/dist/components/MapEditor/MapEditor.svelte +51 -20
- package/dist/components/MapEditor/components/Dialog.svelte +92 -0
- package/dist/components/MapEditor/components/Dialog.svelte.d.ts +17 -0
- package/dist/components/MapEditor/components/DialogFile.svelte +112 -0
- package/dist/components/MapEditor/components/DialogFile.svelte.d.ts +6 -0
- package/dist/components/MapEditor/components/DialogShare.svelte +216 -0
- package/dist/components/MapEditor/components/DialogShare.svelte.d.ts +10 -0
- package/dist/components/MapEditor/components/Editor.svelte +6 -14
- package/dist/components/MapEditor/components/EditorFill.svelte +3 -3
- package/dist/components/MapEditor/components/EditorStroke.svelte +3 -3
- package/dist/components/MapEditor/components/EditorSymbol.svelte +9 -9
- package/dist/components/MapEditor/components/InputRow.svelte +2 -3
- package/dist/components/MapEditor/components/PanelFile.svelte +73 -0
- package/dist/components/MapEditor/components/PanelFile.svelte.d.ts +7 -0
- package/dist/components/MapEditor/components/PanelSymbolSelector.svelte +82 -0
- package/dist/components/MapEditor/components/PanelSymbolSelector.svelte.d.ts +8 -0
- package/dist/components/MapEditor/components/Sidebar.svelte +51 -98
- package/dist/components/MapEditor/components/Sidebar.svelte.d.ts +3 -3
- package/dist/components/MapEditor/components/SidebarPanel.svelte +13 -5
- package/dist/components/MapEditor/lib/element/abstract.d.ts +8 -4
- package/dist/components/MapEditor/lib/element/abstract.js +10 -1
- package/dist/components/MapEditor/lib/element/abstract_path.d.ts +3 -2
- package/dist/components/MapEditor/lib/element/abstract_path.js +6 -3
- package/dist/components/MapEditor/lib/element/circle.d.ts +25 -0
- package/dist/components/MapEditor/lib/element/circle.js +118 -0
- package/dist/components/MapEditor/lib/element/line.d.ts +2 -2
- package/dist/components/MapEditor/lib/element/line.js +1 -1
- package/dist/components/MapEditor/lib/element/marker.d.ts +4 -3
- package/dist/components/MapEditor/lib/element/marker.js +2 -2
- package/dist/components/MapEditor/lib/element/polygon.d.ts +2 -2
- package/dist/components/MapEditor/lib/element/polygon.js +2 -2
- package/dist/components/MapEditor/lib/element/types.d.ts +2 -3
- package/dist/components/MapEditor/lib/geometry_manager.d.ts +12 -29
- package/dist/components/MapEditor/lib/geometry_manager.js +44 -160
- package/dist/components/MapEditor/lib/geometry_manager_interactive.d.ts +33 -0
- package/dist/components/MapEditor/lib/geometry_manager_interactive.js +102 -0
- package/dist/components/MapEditor/lib/map_layer/abstract.d.ts +2 -1
- package/dist/components/MapEditor/lib/map_layer/abstract.js +25 -22
- package/dist/components/MapEditor/lib/map_layer/fill.js +2 -4
- package/dist/components/MapEditor/lib/map_layer/line.js +1 -1
- package/dist/components/MapEditor/lib/map_layer/symbol.js +1 -1
- package/dist/components/MapEditor/lib/selection.d.ts +11 -0
- package/dist/components/MapEditor/lib/selection.js +70 -0
- package/dist/components/MapEditor/lib/state/constants.js +5 -6
- package/dist/components/MapEditor/lib/state/history.d.ts +14 -0
- package/dist/components/MapEditor/lib/state/history.js +53 -0
- package/dist/components/MapEditor/lib/state/manager.d.ts +7 -10
- package/dist/components/MapEditor/lib/state/manager.js +19 -54
- package/dist/components/MapEditor/lib/state/reader.d.ts +6 -4
- package/dist/components/MapEditor/lib/state/reader.js +70 -18
- package/dist/components/MapEditor/lib/state/types.d.ts +19 -2
- package/dist/components/MapEditor/lib/state/utils.d.ts +2 -0
- package/dist/components/MapEditor/lib/state/utils.js +12 -0
- package/dist/components/MapEditor/lib/state/writer.d.ts +6 -4
- package/dist/components/MapEditor/lib/state/writer.js +59 -19
- package/dist/components/MapEditor/lib/symbols.d.ts +1 -1
- package/dist/components/MapEditor/lib/symbols.js +47 -28
- package/dist/components/MapEditor/lib/utils/event_handler.d.ts +10 -0
- package/dist/components/MapEditor/lib/utils/event_handler.js +39 -0
- package/dist/components/MapEditor/lib/utils/geometry.d.ts +12 -0
- package/dist/components/MapEditor/lib/utils/geometry.js +87 -0
- package/dist/components/MapEditor/lib/utils/types.d.ts +2 -0
- package/dist/components/MapEditor/lib/utils/types.js +1 -0
- package/dist/components/MapEditor/style/button.scss +115 -0
- package/dist/components/MapEditor/style/index.scss +3 -0
- package/dist/components/MapEditor/style/layout.scss +20 -0
- package/dist/components/MapEditor/style/other.scss +10 -0
- package/dist/utils/location.d.ts +1 -0
- package/dist/utils/location.js +181 -0
- package/dist/utils/map_style.d.ts +2 -2
- package/dist/utils/map_style.js +2 -2
- package/package.json +29 -29
- package/dist/components/MapEditor/components/SymbolSelector.svelte +0 -110
- package/dist/components/MapEditor/components/SymbolSelector.svelte.d.ts +0 -8
- package/dist/components/MapEditor/lib/utils.d.ts +0 -6
- package/dist/components/MapEditor/lib/utils.js +0 -23
- /package/dist/components/MapEditor/lib/{geocoder.d.ts → utils/geocoder.d.ts} +0 -0
- /package/dist/components/MapEditor/lib/{geocoder.js → utils/geocoder.js} +0 -0
@@ -84,8 +84,7 @@ const entries = [
|
|
84
84
|
[82, 'shield', 'basics:icon-historic', [0, -10]],
|
85
85
|
[83, 'shoes', 'basics:icon-shoes', [-5, 0]],
|
86
86
|
[84, 'shop', 'basics:icon-shop'],
|
87
|
-
[85, '
|
88
|
-
[86, 'shrine', 'basics:icon-shrine'],
|
87
|
+
[85, 'shrine', 'basics:icon-shrine'],
|
89
88
|
[87, 'sports', 'basics:icon-sports'],
|
90
89
|
[88, 'stadium', 'basics:icon-stadium'],
|
91
90
|
[89, 'stationery', 'basics:icon-stationery'],
|
@@ -126,46 +125,66 @@ export class SymbolLibrary {
|
|
126
125
|
getSymbol(index) {
|
127
126
|
return symbols.get(index) ?? defaultSymbol;
|
128
127
|
}
|
129
|
-
drawSymbol(canvas, index, halo =
|
128
|
+
drawSymbol(canvas, index, halo = 0) {
|
130
129
|
const symbol = this.getSymbol(index);
|
131
130
|
if (!symbol.image)
|
132
131
|
return;
|
133
|
-
const { sdf, data:
|
134
|
-
const { data:
|
135
|
-
const { width:
|
136
|
-
const
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
132
|
+
const { sdf, data: imageDataSrc } = this.map.getImage(symbol.image);
|
133
|
+
const { data: dataSrc, width: widthSrc, height: heightSrc } = imageDataSrc;
|
134
|
+
const { width: widthDst, height: heightDst } = canvas;
|
135
|
+
const scale = Math.min(widthDst / widthSrc, heightDst / heightSrc);
|
136
|
+
const x0 = (widthDst - widthSrc * scale) / 2;
|
137
|
+
const y0 = (heightDst - heightSrc * scale) / 2;
|
138
|
+
const border = halo;
|
139
|
+
const dataDst = new Uint8ClampedArray(widthDst * heightDst * 4);
|
140
|
+
for (let yi = 0; yi < heightDst; yi++) {
|
141
|
+
for (let xi = 0; xi < widthDst; xi++) {
|
142
|
+
const x = (xi - x0) / scale;
|
143
|
+
const y = (yi - y0) / scale;
|
144
|
+
const i = (yi * widthDst + xi) * 4;
|
143
145
|
if (sdf) {
|
144
|
-
const v = (
|
145
|
-
let
|
146
|
+
const v = (interpolate(x, y, 3) - 191) * 8 * scale;
|
147
|
+
let alpha, color;
|
146
148
|
if (halo) {
|
147
|
-
|
148
|
-
|
149
|
+
color = Math.min(255, Math.max(0, 127.5 - v));
|
150
|
+
alpha = Math.min(255, Math.max(0, 256 * border + v));
|
149
151
|
}
|
150
152
|
else {
|
151
|
-
|
152
|
-
|
153
|
+
color = 0;
|
154
|
+
alpha = Math.min(255, Math.max(0, v));
|
153
155
|
}
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
156
|
+
dataDst[i] = color;
|
157
|
+
dataDst[i + 1] = color;
|
158
|
+
dataDst[i + 2] = color;
|
159
|
+
dataDst[i + 3] = alpha;
|
158
160
|
}
|
159
161
|
else {
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
162
|
+
dataDst[i] = interpolate(x, y, 0);
|
163
|
+
dataDst[i + 1] = interpolate(x, y, 1);
|
164
|
+
dataDst[i + 2] = interpolate(x, y, 2);
|
165
|
+
dataDst[i + 3] = interpolate(x, y, 3);
|
164
166
|
}
|
165
167
|
}
|
166
168
|
}
|
167
169
|
const ctx = canvas.getContext('2d');
|
168
|
-
ctx.putImageData(new ImageData(
|
170
|
+
ctx.putImageData(new ImageData(dataDst, widthDst, heightDst), 0, 0);
|
171
|
+
function interpolate(x, y, c) {
|
172
|
+
if (x < 0 || y < 0 || x >= widthSrc - 1 || y >= heightSrc - 1)
|
173
|
+
return 0;
|
174
|
+
const x0 = Math.floor(x);
|
175
|
+
const y0 = Math.floor(y);
|
176
|
+
const x1 = Math.ceil(x);
|
177
|
+
const y1 = Math.ceil(y);
|
178
|
+
const xa = (x - x0) / Math.max(1, x1 - x0);
|
179
|
+
const ya = (y - y0) / Math.max(1, y1 - y0);
|
180
|
+
const v00 = dataSrc[(y0 * widthSrc + x0) * 4 + c];
|
181
|
+
const v01 = dataSrc[(y0 * widthSrc + x1) * 4 + c];
|
182
|
+
const v10 = dataSrc[(y1 * widthSrc + x0) * 4 + c];
|
183
|
+
const v11 = dataSrc[(y1 * widthSrc + x1) * 4 + c];
|
184
|
+
const v0 = v00 * (1 - xa) + v01 * xa;
|
185
|
+
const v1 = v10 * (1 - xa) + v11 * xa;
|
186
|
+
return v0 * (1 - ya) + v1 * ya;
|
187
|
+
}
|
169
188
|
}
|
170
189
|
asList() {
|
171
190
|
return Array.from(symbols.values());
|
@@ -0,0 +1,10 @@
|
|
1
|
+
export declare class EventHandler {
|
2
|
+
private index;
|
3
|
+
private events;
|
4
|
+
constructor();
|
5
|
+
emit(event: string): void;
|
6
|
+
on(name: string, callback: () => void): number;
|
7
|
+
once(name: string, callback: () => void): number;
|
8
|
+
off(name: string, index?: number): void;
|
9
|
+
clear(): void;
|
10
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
export class EventHandler {
|
2
|
+
index = 0;
|
3
|
+
events = new Map();
|
4
|
+
constructor() { }
|
5
|
+
emit(event) {
|
6
|
+
this.events.get(event)?.forEach((callback) => callback());
|
7
|
+
}
|
8
|
+
on(name, callback) {
|
9
|
+
if (!callback)
|
10
|
+
throw new Error('Callback is required');
|
11
|
+
if (!this.events.has(name))
|
12
|
+
this.events.set(name, new Map());
|
13
|
+
this.index++;
|
14
|
+
this.events.get(name).set(this.index, callback);
|
15
|
+
return this.index;
|
16
|
+
}
|
17
|
+
once(name, callback) {
|
18
|
+
if (!callback)
|
19
|
+
throw new Error('Callback is required');
|
20
|
+
const index = this.on(name, () => {
|
21
|
+
this.off(name, index);
|
22
|
+
callback();
|
23
|
+
});
|
24
|
+
return index;
|
25
|
+
}
|
26
|
+
off(name, index) {
|
27
|
+
if (!this.events.has(name))
|
28
|
+
return;
|
29
|
+
if (index) {
|
30
|
+
this.events.get(name)?.delete(index);
|
31
|
+
}
|
32
|
+
else {
|
33
|
+
this.events.delete(name);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
clear() {
|
37
|
+
this.events.clear();
|
38
|
+
}
|
39
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import type { GeoPath, GeoPoint } from './types.js';
|
2
|
+
export declare const EARTH_RADIUS = 6371008.8;
|
3
|
+
export declare function getMiddlePoint(p0: GeoPoint, p1: GeoPoint): GeoPoint;
|
4
|
+
export declare function lat2mercator(lat: number): number;
|
5
|
+
export declare function mercator2lat(y: number): number;
|
6
|
+
export declare function distance(point1: GeoPoint, point2: GeoPoint): number;
|
7
|
+
export declare function degreesToRadians(degrees: number): number;
|
8
|
+
export declare function radiansToDegrees(radians: number): number;
|
9
|
+
export declare function circle(center: GeoPoint, radius: number, steps: number): GeoPath;
|
10
|
+
type SimpleGeometry = GeoJSON.Point | GeoJSON.LineString | GeoJSON.Polygon;
|
11
|
+
export declare function flatten(features: GeoJSON.Feature[]): GeoJSON.Feature<SimpleGeometry>[];
|
12
|
+
export {};
|
@@ -0,0 +1,87 @@
|
|
1
|
+
export const EARTH_RADIUS = 6371008.8; // Radius of the Earth in meters
|
2
|
+
export function getMiddlePoint(p0, p1) {
|
3
|
+
const y0 = lat2mercator(p0[1]);
|
4
|
+
const y1 = lat2mercator(p1[1]);
|
5
|
+
return [(p0[0] + p1[0]) / 2, mercator2lat((y0 + y1) / 2)];
|
6
|
+
}
|
7
|
+
export function lat2mercator(lat) {
|
8
|
+
return Math.log(Math.tan(Math.PI / 4 + (lat * Math.PI) / 360));
|
9
|
+
}
|
10
|
+
export function mercator2lat(y) {
|
11
|
+
return ((2 * Math.atan(Math.exp(y)) - Math.PI / 2) * 180) / Math.PI;
|
12
|
+
}
|
13
|
+
export function distance(point1, point2) {
|
14
|
+
const lat1 = degreesToRadians(point1[1]);
|
15
|
+
const lat2 = degreesToRadians(point2[1]);
|
16
|
+
const deltaLat = degreesToRadians(point2[1] - point1[1]);
|
17
|
+
const deltaLng = degreesToRadians(point2[0] - point1[0]);
|
18
|
+
const a = Math.sin(deltaLat / 2) * Math.sin(deltaLat / 2) +
|
19
|
+
Math.cos(lat1) * Math.cos(lat2) * Math.sin(deltaLng / 2) * Math.sin(deltaLng / 2);
|
20
|
+
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
21
|
+
return EARTH_RADIUS * c; // Distance in meters
|
22
|
+
}
|
23
|
+
export function degreesToRadians(degrees) {
|
24
|
+
return ((degrees % 360) * Math.PI) / 180;
|
25
|
+
}
|
26
|
+
export function radiansToDegrees(radians) {
|
27
|
+
return ((radians / Math.PI) % 2) * 180;
|
28
|
+
}
|
29
|
+
export function circle(center, radius, steps) {
|
30
|
+
const radians = radius / EARTH_RADIUS;
|
31
|
+
const lng1 = degreesToRadians(center[0]);
|
32
|
+
const lat1 = degreesToRadians(center[1]);
|
33
|
+
const result = [];
|
34
|
+
for (let i = 0; i < steps; i++) {
|
35
|
+
const bearingRad = degreesToRadians((i * 360) / steps);
|
36
|
+
const lat2 = Math.asin(Math.sin(lat1) * Math.cos(radians) + Math.cos(lat1) * Math.sin(radians) * Math.cos(bearingRad));
|
37
|
+
const lng2 = lng1 +
|
38
|
+
Math.atan2(Math.sin(bearingRad) * Math.sin(radians) * Math.cos(lat1), Math.cos(radians) - Math.sin(lat1) * Math.sin(lat2));
|
39
|
+
result.push([radiansToDegrees(lng2), radiansToDegrees(lat2)]);
|
40
|
+
}
|
41
|
+
return result;
|
42
|
+
}
|
43
|
+
export function flatten(features) {
|
44
|
+
return features.flatMap((feature) => {
|
45
|
+
if (feature.type !== 'Feature') {
|
46
|
+
throw new Error(`Expected Feature, got ${feature.type}`);
|
47
|
+
}
|
48
|
+
return flattenGeometry(feature.geometry, feature.properties);
|
49
|
+
});
|
50
|
+
function flattenGeometry(geometry, properties) {
|
51
|
+
switch (geometry.type) {
|
52
|
+
case 'Point':
|
53
|
+
case 'LineString':
|
54
|
+
case 'Polygon':
|
55
|
+
return [
|
56
|
+
{
|
57
|
+
type: 'Feature',
|
58
|
+
properties,
|
59
|
+
geometry
|
60
|
+
}
|
61
|
+
];
|
62
|
+
case 'GeometryCollection':
|
63
|
+
return geometry.geometries.flatMap((g) => flattenGeometry(g, properties));
|
64
|
+
case 'MultiPoint':
|
65
|
+
return geometry.coordinates.map((coordinates) => ({
|
66
|
+
type: 'Feature',
|
67
|
+
properties,
|
68
|
+
geometry: { type: 'Point', coordinates }
|
69
|
+
}));
|
70
|
+
case 'MultiLineString':
|
71
|
+
return geometry.coordinates.map((coordinates) => ({
|
72
|
+
type: 'Feature',
|
73
|
+
properties,
|
74
|
+
geometry: { type: 'LineString', coordinates }
|
75
|
+
}));
|
76
|
+
case 'MultiPolygon':
|
77
|
+
return geometry.coordinates.map((coordinates) => ({
|
78
|
+
type: 'Feature',
|
79
|
+
properties,
|
80
|
+
geometry: { type: 'Polygon', coordinates }
|
81
|
+
}));
|
82
|
+
default:
|
83
|
+
// @ts-expect-error error on unknown geometry type
|
84
|
+
throw new Error(`Unknown geometry type "${geometry?.type}"`);
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,115 @@
|
|
1
|
+
button.btn,
|
2
|
+
fieldset.btn {
|
3
|
+
font-size: 0.8rem;
|
4
|
+
}
|
5
|
+
|
6
|
+
button.btn,
|
7
|
+
fieldset.btn > div > label {
|
8
|
+
background-color: var(--color-blue);
|
9
|
+
opacity: 0.7;
|
10
|
+
border-radius: var(--border-radius);
|
11
|
+
border: none;
|
12
|
+
color: var(--color-bg);
|
13
|
+
cursor: pointer;
|
14
|
+
display: inline-block;
|
15
|
+
font-weight: 600;
|
16
|
+
position: relative;
|
17
|
+
padding: 0;
|
18
|
+
transition: opacity 0.1s ease-in-out;
|
19
|
+
padding-block: 0.6em;
|
20
|
+
padding-inline: 1.2em;
|
21
|
+
}
|
22
|
+
|
23
|
+
button.btn {
|
24
|
+
&:focus {
|
25
|
+
outline: 1px solid var(--color-blue);
|
26
|
+
outline-offset: 2px;
|
27
|
+
}
|
28
|
+
|
29
|
+
&:not([disabled]):hover {
|
30
|
+
opacity: 1;
|
31
|
+
}
|
32
|
+
|
33
|
+
&:disabled {
|
34
|
+
opacity: 0.3;
|
35
|
+
}
|
36
|
+
|
37
|
+
&:after {
|
38
|
+
content: '✓';
|
39
|
+
background-color: var(--color-green);
|
40
|
+
border-radius: 1em;
|
41
|
+
color: var(--color-bg);
|
42
|
+
display: block;
|
43
|
+
font-size: 1em;
|
44
|
+
height: 1.6em;
|
45
|
+
line-height: 1.6em;
|
46
|
+
margin-left: 5px;
|
47
|
+
opacity: 0;
|
48
|
+
pointer-events: none;
|
49
|
+
position: absolute;
|
50
|
+
right: -0.6em;
|
51
|
+
text-align: center;
|
52
|
+
top: -0.6em;
|
53
|
+
transition: opacity 0.1s ease-in-out;
|
54
|
+
width: 1.6em;
|
55
|
+
}
|
56
|
+
|
57
|
+
&.success {
|
58
|
+
&:after {
|
59
|
+
opacity: 1;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
fieldset.btn {
|
65
|
+
position: relative;
|
66
|
+
display: inline-block;
|
67
|
+
border: none;
|
68
|
+
padding: 0;
|
69
|
+
|
70
|
+
legend {
|
71
|
+
padding-inline: 0;
|
72
|
+
position: absolute;
|
73
|
+
display: block;
|
74
|
+
text-align: center;
|
75
|
+
top: -1.3em;
|
76
|
+
left: 0;
|
77
|
+
right: 0;
|
78
|
+
}
|
79
|
+
|
80
|
+
& > div {
|
81
|
+
border-radius: var(--border-radius);
|
82
|
+
overflow: hidden;
|
83
|
+
border: none;
|
84
|
+
display: inline-flex;
|
85
|
+
padding: 0;
|
86
|
+
|
87
|
+
& > label {
|
88
|
+
margin: 0;
|
89
|
+
border-radius: 0;
|
90
|
+
border: none;
|
91
|
+
border-left: 0.5px solid color-mix(in srgb, var(--color-bg) 20%, transparent);
|
92
|
+
|
93
|
+
&:first-of-type {
|
94
|
+
border-left: none;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
input[type='radio'] {
|
99
|
+
display: none;
|
100
|
+
}
|
101
|
+
|
102
|
+
input:checked + label,
|
103
|
+
label:hover {
|
104
|
+
background-color: var(--color-blue);
|
105
|
+
color: var(--color-bg);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
.label {
|
111
|
+
opacity: 0.5;
|
112
|
+
font-size: 0.7rem;
|
113
|
+
font-weight: normal;
|
114
|
+
margin: 0;
|
115
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
.grid1,
|
2
|
+
.grid2 {
|
3
|
+
display: grid;
|
4
|
+
gap: var(--btn-gap);
|
5
|
+
margin: var(--btn-gap) 0;
|
6
|
+
width: 100%;
|
7
|
+
}
|
8
|
+
|
9
|
+
.grid1 {
|
10
|
+
grid-template-columns: 1fr;
|
11
|
+
}
|
12
|
+
|
13
|
+
.grid2 {
|
14
|
+
grid-template-columns: repeat(2, 1fr);
|
15
|
+
}
|
16
|
+
|
17
|
+
.grid1 > button,
|
18
|
+
.grid2 > button {
|
19
|
+
width: 100%;
|
20
|
+
}
|
package/dist/utils/location.d.ts
CHANGED
@@ -2,3 +2,4 @@ import type { Language } from '@versatiles/style';
|
|
2
2
|
export declare function getCountryName(): string | null;
|
3
3
|
export declare function getCountryCode(): string | null;
|
4
4
|
export declare function getLanguage(): Language;
|
5
|
+
export declare function getCountryBoundingBox(): [number, number, number, number] | null;
|
package/dist/utils/location.js
CHANGED
@@ -38,3 +38,184 @@ export function getLanguage() {
|
|
38
38
|
return null; // Fallback if no country can be determined
|
39
39
|
}
|
40
40
|
}
|
41
|
+
const countryBoundingBoxes = {
|
42
|
+
AF: [60.5, 29.3, 75.2, 38.5],
|
43
|
+
AO: [11.6, -18, 24.1, -4.4],
|
44
|
+
AL: [19.3, 39.6, 21.1, 42.7],
|
45
|
+
AE: [51.5, 22.4, 56.4, 26.1],
|
46
|
+
AR: [-73.5, -55.3, -53.6, -21.8],
|
47
|
+
AM: [43.5, 38.7, 46.6, 41.3],
|
48
|
+
AQ: [-180, -90, 180, -63.2],
|
49
|
+
TF: [68.7, -49.8, 70.6, -48.6],
|
50
|
+
AU: [113.3, -43.7, 153.6, -10.6],
|
51
|
+
AT: [9.4, 46.4, 17, 49.1],
|
52
|
+
AZ: [44.7, 38.2, 50.4, 41.9],
|
53
|
+
BI: [29, -4.5, 30.8, -2.3],
|
54
|
+
BE: [2.5, 49.5, 6.2, 51.5],
|
55
|
+
BJ: [0.7, 6.1, 3.8, 12.3],
|
56
|
+
BF: [-5.5, 9.6, 2.2, 15.2],
|
57
|
+
BD: [88, 20.6, 92.7, 26.5],
|
58
|
+
BG: [22.3, 41.2, 28.6, 44.3],
|
59
|
+
BS: [-79, 23.7, -77, 27.1],
|
60
|
+
BA: [15.7, 42.6, 19.6, 45.3],
|
61
|
+
BY: [23.1, 51.3, 32.7, 56.2],
|
62
|
+
BZ: [-89.3, 15.8, -88.1, 18.5],
|
63
|
+
BO: [-69.6, -22.9, -57.4, -9.7],
|
64
|
+
BR: [-74, -33.8, -34.7, 5.3],
|
65
|
+
BN: [114.2, 4, 115.5, 5.5],
|
66
|
+
BT: [88.8, 26.7, 92.2, 28.3],
|
67
|
+
BW: [19.8, -26.9, 29.5, -17.6],
|
68
|
+
CF: [14.4, 2.2, 27.4, 11.2],
|
69
|
+
CA: [-141, 41.6, -52.6, 83.3],
|
70
|
+
CH: [6, 45.7, 10.5, 47.9],
|
71
|
+
CL: [-75.7, -55.7, -66.9, -17.5],
|
72
|
+
CN: [73.6, 18.1, 135.1, 53.5],
|
73
|
+
CI: [-8.7, 4.3, -2.5, 10.6],
|
74
|
+
CM: [8.4, 1.7, 16.1, 12.9],
|
75
|
+
CD: [12.1, -13.3, 31.2, 5.3],
|
76
|
+
CG: [11, -5.1, 18.5, 3.8],
|
77
|
+
CO: [-79, -4.3, -66.8, 12.5],
|
78
|
+
CR: [-86, 8.2, -82.5, 11.3],
|
79
|
+
CU: [-85, 19.8, -74.1, 23.2],
|
80
|
+
CY: [32.2, 34.5, 34.1, 35.2],
|
81
|
+
CZ: [12.2, 48.5, 18.9, 51.2],
|
82
|
+
DE: [5.9, 47.3, 15.1, 55],
|
83
|
+
DJ: [41.6, 10.9, 43.4, 12.7],
|
84
|
+
DK: [8, 54.8, 12.7, 57.8],
|
85
|
+
DO: [-72, 17.5, -68.3, 19.9],
|
86
|
+
DZ: [-8.7, 19, 12, 37.2],
|
87
|
+
EC: [-81, -5, -75.2, 1.4],
|
88
|
+
EG: [24.7, 22, 36.9, 31.6],
|
89
|
+
ER: [36.3, 12.4, 43.1, 18],
|
90
|
+
ES: [-9.4, 35.9, 3.1, 43.8],
|
91
|
+
EE: [23.3, 57.4, 28.2, 59.7],
|
92
|
+
ET: [32.9, 3.4, 47.8, 15],
|
93
|
+
FI: [20.6, 59.8, 31.6, 70.2],
|
94
|
+
FJ: [-180, -18.3, 180, -16],
|
95
|
+
FK: [-61.2, -52.3, -57.7, -51.1],
|
96
|
+
FR: [-54.6, 2, 9.6, 51.2],
|
97
|
+
GA: [8.7, -4, 14.5, 2.4],
|
98
|
+
GB: [-7.6, 49.9, 1.7, 58.7],
|
99
|
+
GE: [39.9, 41, 46.7, 43.6],
|
100
|
+
GH: [-3.3, 4.7, 1.1, 11.1],
|
101
|
+
GN: [-15.2, 7.3, -7.8, 12.6],
|
102
|
+
GM: [-16.9, 13.1, -13.8, 13.9],
|
103
|
+
GW: [-16.7, 11, -13.7, 12.7],
|
104
|
+
GQ: [9.3, 1, 11.3, 2.3],
|
105
|
+
GR: [20.1, 34.9, 26.7, 41.9],
|
106
|
+
GL: [-73.3, 60, -12.2, 83.7],
|
107
|
+
GT: [-92.3, 13.7, -88.2, 17.9],
|
108
|
+
GY: [-61.5, 1.2, -56.5, 8.4],
|
109
|
+
HN: [-89.4, 12.9, -83.1, 16.1],
|
110
|
+
HR: [13.6, 42.4, 19.4, 46.6],
|
111
|
+
HT: [-74.5, 18, -71.6, 20],
|
112
|
+
HU: [16.2, 45.7, 22.8, 48.7],
|
113
|
+
ID: [95.2, -10.4, 141.1, 5.5],
|
114
|
+
IN: [68.1, 7.9, 97.5, 35.5],
|
115
|
+
IE: [-10, 51.6, -6, 55.2],
|
116
|
+
IR: [44.1, 25, 63.4, 39.8],
|
117
|
+
IQ: [38.7, 29, 48.6, 37.4],
|
118
|
+
IS: [-24.4, 63.4, -13.6, 66.6],
|
119
|
+
IL: [34.2, 29.5, 35.9, 33.3],
|
120
|
+
IT: [6.7, 36.6, 18.5, 47.2],
|
121
|
+
JM: [-78.4, 17.7, -76.1, 18.6],
|
122
|
+
JO: [34.9, 29.1, 39.2, 33.4],
|
123
|
+
JP: [129.4, 31, 145.6, 45.6],
|
124
|
+
KZ: [46.4, 40.6, 87.4, 55.4],
|
125
|
+
KE: [33.8, -4.7, 41.9, 5.6],
|
126
|
+
KG: [69.4, 39.2, 80.3, 43.3],
|
127
|
+
KH: [102.3, 10.4, 107.7, 14.6],
|
128
|
+
KR: [126.1, 34.3, 129.5, 38.7],
|
129
|
+
KW: [46.5, 28.5, 48.5, 30.1],
|
130
|
+
LA: [100.1, 13.8, 107.6, 22.5],
|
131
|
+
LB: [35.1, 33, 36.7, 34.7],
|
132
|
+
LR: [-11.5, 4.3, -7.5, 8.6],
|
133
|
+
LY: [9.3, 19.5, 25.2, 33.2],
|
134
|
+
LK: [79.6, 5.9, 81.8, 9.9],
|
135
|
+
LS: [26.9, -30.7, 29.4, -28.6],
|
136
|
+
LT: [21, 53.9, 26.6, 56.4],
|
137
|
+
LU: [5.6, 49.4, 6.3, 50.2],
|
138
|
+
LV: [21, 55.6, 28.2, 58],
|
139
|
+
MA: [-17.1, 21.4, -1.1, 35.8],
|
140
|
+
MD: [26.6, 45.4, 30.1, 48.5],
|
141
|
+
MG: [43.2, -25.7, 50.5, -12],
|
142
|
+
MX: [-117.2, 14.5, -86.8, 32.8],
|
143
|
+
MK: [20.4, 40.8, 23, 42.4],
|
144
|
+
ML: [-12.2, 10, 4.3, 25],
|
145
|
+
MM: [92.3, 9.9, 101.2, 28.4],
|
146
|
+
ME: [18.4, 41.8, 20.4, 43.6],
|
147
|
+
MN: [87.7, 41.5, 119.8, 52.1],
|
148
|
+
MZ: [30.1, -26.8, 40.8, -10.3],
|
149
|
+
MR: [-17.1, 14.6, -4.9, 27.4],
|
150
|
+
MW: [32.6, -16.9, 35.8, -9.2],
|
151
|
+
MY: [100, 0.7, 119.2, 7],
|
152
|
+
NA: [11.7, -29.1, 25.1, -16.9],
|
153
|
+
NC: [164, -22.4, 167.2, -20.1],
|
154
|
+
NE: [0.2, 11.6, 16, 23.5],
|
155
|
+
NG: [2.6, 4.2, 14.6, 13.9],
|
156
|
+
NI: [-87.7, 10.7, -83.1, 15.1],
|
157
|
+
NL: [3.3, 50.8, 7.1, 53.6],
|
158
|
+
NO: [4.9, 58, 31.3, 80.7],
|
159
|
+
NP: [80, 26.3, 88.2, 30.5],
|
160
|
+
NZ: [166.5, -46.7, 178.6, -34.4],
|
161
|
+
OM: [52, 16.6, 59.9, 26.4],
|
162
|
+
PK: [60.8, 23.6, 77.9, 37.2],
|
163
|
+
PA: [-83, 7.2, -77.2, 9.7],
|
164
|
+
PE: [-81.5, -18.4, -68.6, 0],
|
165
|
+
PH: [117.1, 5.5, 126.6, 18.6],
|
166
|
+
PG: [141, -10.7, 156.1, -2.5],
|
167
|
+
PL: [14, 49, 24.1, 54.9],
|
168
|
+
PR: [-67.3, 17.9, -65.5, 18.6],
|
169
|
+
KP: [124.2, 37.6, 130.8, 43],
|
170
|
+
PT: [-9.6, 36.8, -6.3, 42.3],
|
171
|
+
PY: [-62.7, -27.6, -54.2, -19.3],
|
172
|
+
QA: [50.7, 24.5, 51.7, 26.2],
|
173
|
+
RO: [20.2, 43.6, 29.7, 48.3],
|
174
|
+
RU: [-180, 41.1, 180, 81.3],
|
175
|
+
RW: [29, -3, 30.9, -1.1],
|
176
|
+
SA: [34.6, 16.3, 55.7, 32.2],
|
177
|
+
SD: [21.9, 8.6, 38.5, 22],
|
178
|
+
SS: [23.8, 3.5, 35.3, 12.3],
|
179
|
+
SN: [-17.7, 12.3, -11.4, 16.6],
|
180
|
+
SB: [156.4, -10.9, 162.4, -6.5],
|
181
|
+
SL: [-13.3, 6.7, -10.2, 10.1],
|
182
|
+
SV: [-90.1, 13.1, -87.7, 14.5],
|
183
|
+
SO: [40.9, -1.7, 51.2, 12.1],
|
184
|
+
RS: [18.8, 42.2, 23, 46.2],
|
185
|
+
SR: [-58.1, 1.8, -53.9, 6.1],
|
186
|
+
SK: [16.8, 47.7, 22.6, 49.6],
|
187
|
+
SI: [13.6, 45.4, 16.6, 46.9],
|
188
|
+
SE: [11, 55.3, 24, 69.2],
|
189
|
+
SZ: [30.6, -27.3, 32.1, -25.6],
|
190
|
+
SY: [35.7, 32.3, 42.4, 37.3],
|
191
|
+
TD: [13.5, 7.4, 23.9, 23.5],
|
192
|
+
TG: [-0.1, 5.9, 1.9, 11.1],
|
193
|
+
TH: [97.3, 5.6, 105.6, 20.5],
|
194
|
+
TJ: [67.4, 36.7, 75, 41],
|
195
|
+
TM: [52.5, 35.2, 66.6, 42.8],
|
196
|
+
TL: [124.9, -9.4, 127.4, -8.2],
|
197
|
+
TT: [-62, 10, -60.8, 10.9],
|
198
|
+
TN: [7.5, 30.3, 11.5, 37.4],
|
199
|
+
TR: [26, 35.8, 44.8, 42.2],
|
200
|
+
TW: [120.1, 21.9, 122, 25.3],
|
201
|
+
TZ: [29.3, -11.8, 40.4, -0.9],
|
202
|
+
UG: [29.5, -1.5, 35.1, 4.3],
|
203
|
+
UA: [22, 44.3, 40.1, 52.4],
|
204
|
+
UY: [-58.5, -35, -53.2, -30.1],
|
205
|
+
US: [-171.8, 18.9, -66.9, 71.4],
|
206
|
+
UZ: [55.9, 37.1, 73.1, 45.6],
|
207
|
+
VE: [-73.4, 0.7, -59.7, 12.2],
|
208
|
+
VN: [102.1, 8.5, 109.4, 23.4],
|
209
|
+
VU: [166.6, -16.6, 167.9, -14.6],
|
210
|
+
PS: [34.9, 31.3, 35.6, 32.6],
|
211
|
+
YE: [42.6, 12.5, 53.2, 19.1],
|
212
|
+
ZA: [16.3, -34.9, 32.9, -22],
|
213
|
+
ZM: [21.8, -18, 33.5, -8.2],
|
214
|
+
ZW: [25.2, -22.3, 32.9, -15.5]
|
215
|
+
};
|
216
|
+
export function getCountryBoundingBox() {
|
217
|
+
const countryCode = getCountryCode();
|
218
|
+
if (!countryCode)
|
219
|
+
return null;
|
220
|
+
return countryBoundingBoxes[countryCode] ?? null;
|
221
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { type StyleBuilderOptions } from '@versatiles/style';
|
2
|
-
export declare function getMapStyle(
|
2
|
+
export declare function getMapStyle(styleOptions?: StyleBuilderOptions & {
|
3
|
+
darkMode?: boolean;
|
3
4
|
transitionDuration?: number;
|
4
|
-
disableDarkMode?: boolean;
|
5
5
|
}): import("maplibre-gl").StyleSpecification;
|
6
6
|
export declare function isDarkMode(element?: HTMLElement): boolean;
|
package/dist/utils/map_style.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { styles } from '@versatiles/style';
|
2
2
|
import { getLanguage } from './location.js';
|
3
|
-
export function getMapStyle(
|
4
|
-
darkMode = darkMode
|
3
|
+
export function getMapStyle(styleOptions = {}) {
|
4
|
+
const darkMode = styleOptions.darkMode ?? isDarkMode();
|
5
5
|
const style = styles.colorful({
|
6
6
|
baseUrl: 'https://tiles.versatiles.org',
|
7
7
|
language: getLanguage(),
|