@versatiles/svelte 1.1.1 → 2.0.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/AutoComplete.svelte +0 -1
- package/dist/components/BBoxMap/BBoxMap.svelte +1 -2
- package/dist/{utils/draw → components/BBoxMap/lib}/bbox.d.ts +1 -2
- package/dist/components/BasicMap/BasicMap.svelte +7 -9
- package/dist/components/BasicMap/BasicMap.svelte.d.ts +5 -4
- package/dist/components/LocatorMap/LocatorMap.svelte +0 -2
- package/dist/components/MapEditor/MapEditor.svelte +16 -3
- package/dist/components/MapEditor/components/Editor.svelte +46 -39
- package/dist/components/MapEditor/components/Editor.svelte.d.ts +1 -1
- package/dist/components/MapEditor/components/EditorFill.svelte +7 -9
- package/dist/components/MapEditor/components/EditorStroke.svelte +9 -11
- package/dist/components/MapEditor/components/EditorSymbol.svelte +23 -19
- package/dist/components/MapEditor/components/InputRow.svelte +34 -0
- package/dist/components/MapEditor/components/InputRow.svelte.d.ts +9 -0
- package/dist/components/MapEditor/components/Sidebar.svelte +116 -111
- package/dist/components/MapEditor/components/SidebarPanel.svelte +92 -0
- package/dist/components/MapEditor/components/SidebarPanel.svelte.d.ts +10 -0
- package/dist/components/MapEditor/components/SymbolSelector.svelte +7 -15
- package/dist/components/MapEditor/lib/element/abstract.d.ts +3 -3
- package/dist/components/MapEditor/lib/element/abstract.js +1 -1
- package/dist/components/MapEditor/lib/element/line.d.ts +3 -4
- package/dist/components/MapEditor/lib/element/line.js +0 -1
- package/dist/components/MapEditor/lib/element/marker.d.ts +4 -4
- package/dist/components/MapEditor/lib/element/polygon.d.ts +3 -3
- package/dist/components/MapEditor/lib/geometry_manager.d.ts +20 -10
- package/dist/components/MapEditor/lib/geometry_manager.js +46 -52
- package/dist/components/MapEditor/lib/map_layer/abstract.d.ts +4 -3
- package/dist/components/MapEditor/lib/map_layer/abstract.js +30 -12
- package/dist/components/MapEditor/lib/map_layer/fill.d.ts +4 -3
- package/dist/components/MapEditor/lib/map_layer/fill.js +9 -8
- package/dist/components/MapEditor/lib/map_layer/line.d.ts +4 -3
- package/dist/components/MapEditor/lib/map_layer/line.js +15 -14
- package/dist/components/MapEditor/lib/map_layer/symbol.d.ts +21 -10
- package/dist/components/MapEditor/lib/map_layer/symbol.js +72 -31
- package/dist/components/MapEditor/lib/state/constants.d.ts +4 -0
- package/dist/components/MapEditor/lib/state/constants.js +22 -0
- package/dist/components/MapEditor/lib/state/manager.d.ts +16 -0
- package/dist/components/MapEditor/lib/state/manager.js +76 -0
- package/dist/components/MapEditor/lib/state/reader.d.ts +21 -14
- package/dist/components/MapEditor/lib/state/reader.js +259 -139
- package/dist/components/MapEditor/lib/state/types.d.ts +28 -12
- package/dist/components/MapEditor/lib/state/writer.d.ts +18 -14
- package/dist/components/MapEditor/lib/state/writer.js +183 -156
- package/dist/components/MapEditor/lib/utils.d.ts +2 -5
- package/dist/components/MapEditor/lib/utils.js +0 -19
- package/package.json +28 -27
- package/dist/components/MapEditor/lib/__mocks__/cursor.d.ts +0 -5
- package/dist/components/MapEditor/lib/__mocks__/cursor.js +0 -6
- package/dist/components/MapEditor/lib/__mocks__/geometry_manager.d.ts +0 -22
- package/dist/components/MapEditor/lib/__mocks__/geometry_manager.js +0 -21
- package/dist/components/MapEditor/lib/__mocks__/map.d.ts +0 -36
- package/dist/components/MapEditor/lib/__mocks__/map.js +0 -26
- /package/dist/{utils/draw → components/BBoxMap/lib}/bbox.js +0 -0
@@ -1,14 +1,14 @@
|
|
1
1
|
<script lang="ts">
|
2
|
-
import type { AbstractElement } from '../lib/element/abstract.js';
|
3
2
|
import Editor from './Editor.svelte';
|
4
3
|
import type { GeometryManager } from '../lib/geometry_manager.js';
|
4
|
+
import SidebarPanel from './SidebarPanel.svelte';
|
5
5
|
|
6
6
|
const { geometryManager, width }: { geometryManager: GeometryManager; width: number } = $props();
|
7
7
|
|
8
|
-
let
|
9
|
-
$
|
10
|
-
|
11
|
-
|
8
|
+
let history = geometryManager.state;
|
9
|
+
let undoEnabled = $state(geometryManager.state.undoEnabled);
|
10
|
+
let redoEnabled = $state(geometryManager.state.redoEnabled);
|
11
|
+
let activeElement = geometryManager.selectedElement;
|
12
12
|
|
13
13
|
function importGeoJSON() {
|
14
14
|
const input = document.createElement('input');
|
@@ -45,135 +45,140 @@
|
|
45
45
|
a.click();
|
46
46
|
URL.revokeObjectURL(url);
|
47
47
|
}
|
48
|
+
|
49
|
+
function getLink() {
|
50
|
+
const url = new URL(window.location.href);
|
51
|
+
url.hash = geometryManager.state.getHash();
|
52
|
+
return url.href;
|
53
|
+
}
|
54
|
+
|
55
|
+
function copyLink() {
|
56
|
+
navigator.clipboard.writeText(getLink()).then(
|
57
|
+
() => alert('Link copied to clipboard!'),
|
58
|
+
() => alert('Failed to copy link. Please try again.')
|
59
|
+
);
|
60
|
+
}
|
61
|
+
|
62
|
+
function copyEmbedCode() {
|
63
|
+
const html = `<iframe style="width:100%; height:60vh" src="${getLink()}"></iframe>`;
|
64
|
+
navigator.clipboard.writeText(html).then(
|
65
|
+
() => alert('Embed code copied to clipboard!'),
|
66
|
+
() => alert('Failed to copy embed code. Please try again.')
|
67
|
+
);
|
68
|
+
}
|
48
69
|
</script>
|
49
70
|
|
50
|
-
<div class="sidebar" style="
|
51
|
-
<div style="
|
52
|
-
<div class="
|
53
|
-
|
54
|
-
<
|
55
|
-
<input type="button" value="Export" onclick={exportGeoJSON} />
|
56
|
-
</div>
|
57
|
-
<hr />
|
58
|
-
<div class="label">Add new:</div>
|
59
|
-
<div class="row-flex">
|
60
|
-
<input
|
61
|
-
type="button"
|
62
|
-
value="Marker"
|
63
|
-
onclick={() => (activeElement = geometryManager.addNewMarker())}
|
64
|
-
/>
|
65
|
-
<input
|
66
|
-
type="button"
|
67
|
-
value="Line"
|
68
|
-
onclick={() => (activeElement = geometryManager.addNewLine())}
|
69
|
-
/>
|
70
|
-
<input
|
71
|
-
type="button"
|
72
|
-
value="Polygon"
|
73
|
-
onclick={() => (activeElement = geometryManager.addNewPolygon())}
|
74
|
-
/>
|
71
|
+
<div class="sidebar" style="width: {width}px;">
|
72
|
+
<div style="margin-bottom: 36px;">
|
73
|
+
<div class="flex flex-two">
|
74
|
+
<button onclick={() => history.undo()} disabled={!$undoEnabled}>Undo</button>
|
75
|
+
<button onclick={() => history.redo()} disabled={!$redoEnabled}>Redo</button>
|
75
76
|
</div>
|
76
|
-
|
77
|
-
<
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
<
|
83
|
-
|
84
|
-
|
77
|
+
<SidebarPanel title="Share map" open={false}>
|
78
|
+
<div class="flex flex-one">
|
79
|
+
<button value="Link" onclick={copyLink}>Link</button>
|
80
|
+
<button onclick={copyEmbedCode}>Embed Code</button>
|
81
|
+
</div>
|
82
|
+
</SidebarPanel>
|
83
|
+
<SidebarPanel title="Import/Export" open={false}>
|
84
|
+
<div class="flex flex-one">
|
85
|
+
<button onclick={importGeoJSON}>Import GeoJSON</button>
|
86
|
+
<button onclick={exportGeoJSON}>Export GeoJSON</button>
|
87
|
+
</div>
|
88
|
+
</SidebarPanel>
|
89
|
+
<SidebarPanel title="Add new">
|
90
|
+
<div class="flex flex-two">
|
91
|
+
<button onclick={() => activeElement.set(geometryManager.addNewMarker())}>Marker</button>
|
92
|
+
<button onclick={() => activeElement.set(geometryManager.addNewLine())}>Line</button>
|
93
|
+
<button onclick={() => activeElement.set(geometryManager.addNewPolygon())}>Polygon</button>
|
94
|
+
<button disabled>Circle</button>
|
95
|
+
</div>
|
96
|
+
</SidebarPanel>
|
97
|
+
<Editor element={$activeElement} />
|
98
|
+
<SidebarPanel title="Actions" disabled={!$activeElement}>
|
99
|
+
<div class="flex flex-two">
|
100
|
+
<button onclick={() => $activeElement!.delete()}>Delete</button>
|
101
|
+
</div>
|
102
|
+
</SidebarPanel>
|
103
|
+
<SidebarPanel title="Help">
|
104
|
+
<a
|
105
|
+
id="github_link"
|
106
|
+
href="https://github.com/versatiles-org/node-versatiles-svelte/issues"
|
107
|
+
target="_blank"
|
108
|
+
aria-label="Repository on GitHub">Report Bugs and Feature Requests as GitHub Issues</a
|
109
|
+
>
|
110
|
+
</SidebarPanel>
|
85
111
|
</div>
|
86
112
|
</div>
|
87
113
|
|
88
114
|
<style>
|
89
115
|
.sidebar {
|
90
|
-
|
116
|
+
--color-btn: #336680;
|
117
|
+
--color-bg: #ffffff;
|
118
|
+
--color-text: #000000;
|
119
|
+
--gap: 10px;
|
120
|
+
|
121
|
+
background-color: rgb(from var(--color-bg) r g b/ 0.7);
|
122
|
+
backdrop-filter: blur(10px);
|
123
|
+
box-sizing: border-box;
|
124
|
+
color: var(--color-text);
|
125
|
+
font-size: 0.8em;
|
91
126
|
height: 100%;
|
127
|
+
overflow-y: scroll;
|
128
|
+
padding: var(--gap);
|
92
129
|
position: absolute;
|
93
|
-
top: 0;
|
94
130
|
right: 0;
|
95
|
-
|
96
|
-
|
97
|
-
box-sizing: border-box;
|
98
|
-
padding: 0.5em var(--gap) 0;
|
99
|
-
border-left: 0.5px solid rgba(0, 0, 0, 0.5);
|
100
|
-
|
101
|
-
hr {
|
102
|
-
border: none;
|
103
|
-
border-top: 0.5px solid rgba(0, 0, 0, 1);
|
104
|
-
margin: var(--gap) 0 var(--gap);
|
105
|
-
}
|
106
|
-
|
107
|
-
:global(h2) {
|
108
|
-
font-size: 0.9em;
|
109
|
-
font-weight: normal;
|
110
|
-
opacity: 0.5;
|
111
|
-
padding-top: var(--gap);
|
112
|
-
border-top: 0.5px solid rgba(0, 0, 0, 1);
|
113
|
-
margin: var(--gap) 0 var(--gap);
|
114
|
-
text-align: center;
|
115
|
-
}
|
131
|
+
top: 0;
|
132
|
+
width: 200px;
|
116
133
|
|
117
|
-
|
118
|
-
|
134
|
+
.flex {
|
135
|
+
--gap: 5px;
|
136
|
+
align-items: center;
|
119
137
|
display: flex;
|
138
|
+
flex-wrap: wrap;
|
139
|
+
gap: var(--gap);
|
120
140
|
justify-content: space-between;
|
121
|
-
column-gap: var(--gap);
|
122
|
-
:global(input) {
|
123
|
-
flex-grow: 0;
|
124
|
-
}
|
125
|
-
}
|
126
|
-
|
127
|
-
:global(.row-input) {
|
128
141
|
margin: var(--gap) 0 var(--gap);
|
129
|
-
|
130
|
-
justify-content: space-between;
|
131
|
-
align-items: center;
|
132
|
-
& > :global(label) {
|
133
|
-
flex-grow: 0;
|
134
|
-
}
|
135
|
-
& > :global(button),
|
136
|
-
& > :global(input),
|
137
|
-
& > :global(select) {
|
138
|
-
width: 60%;
|
139
|
-
flex-grow: 0;
|
140
|
-
}
|
141
|
-
& > :global(input[type='checkbox']) {
|
142
|
-
width: auto;
|
143
|
-
}
|
142
|
+
width: 100%;
|
144
143
|
}
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
font-size: 0.8em;
|
144
|
+
.flex-two button {
|
145
|
+
flex-grow: 1;
|
146
|
+
flex-basis: 0;
|
147
|
+
width: 40%;
|
150
148
|
}
|
151
149
|
|
152
|
-
|
153
|
-
:global(input),
|
154
|
-
:global(select) {
|
150
|
+
.flex-one button {
|
155
151
|
width: 100%;
|
156
|
-
box-sizing: border-box;
|
157
|
-
margin: 0;
|
158
152
|
}
|
159
153
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
154
|
+
button {
|
155
|
+
background-color: var(--color-btn);
|
156
|
+
border: 2px solid var(--color-btn);
|
157
|
+
border-radius: 0.2em;
|
158
|
+
color: var(--color-bg);
|
159
|
+
cursor: pointer;
|
160
|
+
font-weight: 600;
|
161
|
+
padding: 0.4em 1em;
|
162
|
+
transition:
|
163
|
+
background-color 0.1s ease-in-out,
|
164
|
+
color 0.1s ease-in-out;
|
165
|
+
|
166
|
+
&:not([disabled]):hover {
|
167
|
+
background-color: var(--color-bg);
|
168
|
+
color: var(--color-btn);
|
169
|
+
}
|
170
|
+
&:disabled {
|
171
|
+
cursor: not-allowed;
|
172
|
+
opacity: 0.5;
|
173
|
+
}
|
164
174
|
}
|
175
|
+
}
|
165
176
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
text-decoration: none;
|
172
|
-
opacity: 0.3;
|
173
|
-
&:hover {
|
174
|
-
opacity: 1;
|
175
|
-
}
|
176
|
-
}
|
177
|
+
a {
|
178
|
+
text-decoration: none;
|
179
|
+
color: var(--fg-color);
|
180
|
+
&:hover {
|
181
|
+
text-decoration: underline;
|
177
182
|
}
|
178
183
|
}
|
179
184
|
</style>
|
@@ -0,0 +1,92 @@
|
|
1
|
+
<script lang="ts">
|
2
|
+
import type { Snippet } from 'svelte';
|
3
|
+
|
4
|
+
let {
|
5
|
+
children,
|
6
|
+
open = true,
|
7
|
+
title,
|
8
|
+
disabled = false
|
9
|
+
}: { children: Snippet; disabled?: boolean; open?: boolean; title: string } = $props();
|
10
|
+
</script>
|
11
|
+
|
12
|
+
<div class={{ panel: true, open, disabled }}>
|
13
|
+
<button class="header" onclick={() => (open = !open)}>
|
14
|
+
<span class="title">{title}</span>
|
15
|
+
<div class="chevron">
|
16
|
+
<svg viewBox="0 0 7 12">
|
17
|
+
<path d="M1,0L7,6L1,12L0,11,L5,6L0,1z" />
|
18
|
+
</svg>
|
19
|
+
</div>
|
20
|
+
</button>
|
21
|
+
<div class="content">
|
22
|
+
{@render children()}
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
|
26
|
+
<style>
|
27
|
+
.panel {
|
28
|
+
margin: 1em 0;
|
29
|
+
|
30
|
+
.header {
|
31
|
+
background: none;
|
32
|
+
border: none;
|
33
|
+
color: var(--color-text);
|
34
|
+
cursor: pointer;
|
35
|
+
font-weight: 600;
|
36
|
+
margin: 0;
|
37
|
+
padding: 0;
|
38
|
+
position: relative;
|
39
|
+
text-align: left;
|
40
|
+
width: 100%;
|
41
|
+
|
42
|
+
.title {
|
43
|
+
text-transform: uppercase;
|
44
|
+
opacity: 0.8;
|
45
|
+
}
|
46
|
+
.chevron {
|
47
|
+
box-sizing: border-box;
|
48
|
+
display: block;
|
49
|
+
height: 1em;
|
50
|
+
opacity: 0.7;
|
51
|
+
padding: 0;
|
52
|
+
position: absolute;
|
53
|
+
right: 0.4em;
|
54
|
+
top: 0;
|
55
|
+
width: 1em;
|
56
|
+
svg {
|
57
|
+
fill: var(--color-fg);
|
58
|
+
width: 100%;
|
59
|
+
height: 100%;
|
60
|
+
rotate: 0deg;
|
61
|
+
transition: rotate 0.1s linear;
|
62
|
+
transform-origin: 40% 50%;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
66
|
+
.content {
|
67
|
+
height: 0;
|
68
|
+
overflow: hidden;
|
69
|
+
padding: 0;
|
70
|
+
box-sizing: border-box;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
.open {
|
74
|
+
margin-bottom: 2em;
|
75
|
+
.header {
|
76
|
+
.chevron {
|
77
|
+
svg {
|
78
|
+
rotate: 90deg;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
.content {
|
83
|
+
height: auto;
|
84
|
+
}
|
85
|
+
}
|
86
|
+
.disabled {
|
87
|
+
opacity: 0.3;
|
88
|
+
.content {
|
89
|
+
display: none;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
</style>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import type { Snippet } from 'svelte';
|
2
|
+
type $$ComponentProps = {
|
3
|
+
children: Snippet;
|
4
|
+
disabled?: boolean;
|
5
|
+
open?: boolean;
|
6
|
+
title: string;
|
7
|
+
};
|
8
|
+
declare const SidebarPanel: import("svelte").Component<$$ComponentProps, {}, "">;
|
9
|
+
type SidebarPanel = ReturnType<typeof SidebarPanel>;
|
10
|
+
export default SidebarPanel;
|
@@ -7,17 +7,17 @@
|
|
7
7
|
symbolLibrary
|
8
8
|
}: { symbolIndex: number; symbolLibrary: SymbolLibrary } = $props();
|
9
9
|
|
10
|
-
let open = $state(false);
|
11
|
-
|
12
10
|
const drawIconHalo: Action<HTMLCanvasElement, number> = (canvas, index) =>
|
13
11
|
symbolLibrary.drawSymbol(canvas, index, true);
|
14
12
|
|
15
13
|
const drawIcon: Action<HTMLCanvasElement, number> = (canvas, index) =>
|
16
14
|
symbolLibrary.drawSymbol(canvas, index);
|
15
|
+
|
16
|
+
let dialog: HTMLDialogElement | null = null;
|
17
17
|
</script>
|
18
18
|
|
19
19
|
<button
|
20
|
-
onclick={() => (
|
20
|
+
onclick={() => dialog?.showModal()}
|
21
21
|
style="text-align: left; white-space: nowrap; overflow: hidden; padding: 1px"
|
22
22
|
>
|
23
23
|
{#key symbolIndex}
|
@@ -35,28 +35,20 @@
|
|
35
35
|
{/if}
|
36
36
|
</button>
|
37
37
|
|
38
|
-
<
|
39
|
-
<button class="close" onclick={() => (
|
38
|
+
<dialog class="modal" bind:this={dialog}>
|
39
|
+
<button class="close" onclick={() => dialog?.close()}>✕</button>
|
40
40
|
<div class="inner">
|
41
41
|
{#each symbolLibrary.asList() as symbol (symbol.index)}
|
42
|
-
<button
|
43
|
-
class="icon"
|
44
|
-
onclick={() => {
|
45
|
-
symbolIndex = symbol.index;
|
46
|
-
open = false;
|
47
|
-
}}
|
42
|
+
<button class="icon" onclick={() => (symbolIndex = symbol.index)}
|
48
43
|
><canvas width="64" height="64" use:drawIconHalo={symbol.index}></canvas><br
|
49
44
|
/>{symbol.name}</button
|
50
45
|
>
|
51
46
|
{/each}
|
52
47
|
</div>
|
53
|
-
</
|
48
|
+
</dialog>
|
54
49
|
|
55
50
|
<style>
|
56
51
|
.modal {
|
57
|
-
position: fixed;
|
58
|
-
top: max(calc(50vh - 250px), 0px);
|
59
|
-
left: max(calc(50vw - 250px), 0px);
|
60
52
|
width: min(500px, 100vw);
|
61
53
|
height: min(500px, 100vh);
|
62
54
|
background-color: rgba(255, 255, 255, 0.5);
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { ElementPoint, SelectionNode, SelectionNodeUpdater } from './types.js';
|
2
2
|
import type { GeometryManager } from '../geometry_manager.js';
|
3
|
-
import type {
|
3
|
+
import type { StateElement } from '../state/types.js';
|
4
4
|
export declare abstract class AbstractElement {
|
5
5
|
protected readonly canvas: HTMLElement;
|
6
6
|
protected readonly manager: GeometryManager;
|
@@ -14,8 +14,8 @@ export declare abstract class AbstractElement {
|
|
14
14
|
protected randomPositions(length: number): ElementPoint[];
|
15
15
|
delete(): void;
|
16
16
|
abstract destroy(): void;
|
17
|
-
abstract getFeature(includeProperties
|
17
|
+
abstract getFeature(includeProperties?: boolean): GeoJSON.Feature;
|
18
18
|
abstract getSelectionNodes(): SelectionNode[];
|
19
19
|
abstract getSelectionNodeUpdater(properties?: Record<string, unknown>): SelectionNodeUpdater | undefined;
|
20
|
-
abstract getState():
|
20
|
+
abstract getState(): StateElement;
|
21
21
|
}
|
@@ -2,15 +2,14 @@ import type { GeometryManager } from '../geometry_manager.js';
|
|
2
2
|
import type { ElementPath } from './types.js';
|
3
3
|
import { MapLayerLine } from '../map_layer/line.js';
|
4
4
|
import { AbstractPathElement } from './abstract_path.js';
|
5
|
-
import type {
|
5
|
+
import type { StateElementLine } from '../state/types.js';
|
6
6
|
export declare class LineElement extends AbstractPathElement {
|
7
7
|
readonly layer: MapLayerLine;
|
8
|
-
readonly path: ElementPath;
|
9
8
|
constructor(manager: GeometryManager, line?: ElementPath);
|
10
9
|
select(value: boolean): void;
|
11
10
|
getFeature(includeProperties?: boolean): GeoJSON.Feature<GeoJSON.LineString>;
|
12
11
|
destroy(): void;
|
13
|
-
getState():
|
14
|
-
static fromState(manager: GeometryManager, state:
|
12
|
+
getState(): StateElementLine;
|
13
|
+
static fromState(manager: GeometryManager, state: StateElementLine): LineElement;
|
15
14
|
static fromGeoJSON(manager: GeometryManager, feature: GeoJSON.Feature<GeoJSON.LineString>): LineElement;
|
16
15
|
}
|
@@ -2,7 +2,6 @@ import { MapLayerLine } from '../map_layer/line.js';
|
|
2
2
|
import { AbstractPathElement } from './abstract_path.js';
|
3
3
|
export class LineElement extends AbstractPathElement {
|
4
4
|
layer;
|
5
|
-
path;
|
6
5
|
constructor(manager, line) {
|
7
6
|
super(manager, true);
|
8
7
|
this.path = line ?? this.randomPositions(2);
|
@@ -2,17 +2,17 @@ import { AbstractElement } from './abstract.js';
|
|
2
2
|
import type { GeometryManager } from '../geometry_manager.js';
|
3
3
|
import type { ElementPoint, SelectionNode, SelectionNodeUpdater } from './types.js';
|
4
4
|
import { MapLayerSymbol } from '../map_layer/symbol.js';
|
5
|
-
import type {
|
5
|
+
import type { StateElementMarker } from '../state/types.js';
|
6
6
|
export declare class MarkerElement extends AbstractElement {
|
7
7
|
readonly layer: MapLayerSymbol;
|
8
|
-
|
8
|
+
point: ElementPoint;
|
9
9
|
constructor(manager: GeometryManager, point?: ElementPoint);
|
10
10
|
select(value: boolean): void;
|
11
11
|
getFeature(includeProperties?: boolean): GeoJSON.Feature<GeoJSON.Point>;
|
12
12
|
getSelectionNodes(): SelectionNode[];
|
13
13
|
getSelectionNodeUpdater(): SelectionNodeUpdater | undefined;
|
14
14
|
destroy(): void;
|
15
|
-
getState():
|
16
|
-
static fromState(manager: GeometryManager, state:
|
15
|
+
getState(): StateElementMarker;
|
16
|
+
static fromState(manager: GeometryManager, state: StateElementMarker): MarkerElement;
|
17
17
|
static fromGeoJSON(manager: GeometryManager, feature: GeoJSON.Feature<GeoJSON.Point>): MarkerElement;
|
18
18
|
}
|
@@ -3,7 +3,7 @@ import type { ElementPath } from './types.js';
|
|
3
3
|
import { MapLayerFill } from '../map_layer/fill.js';
|
4
4
|
import { MapLayerLine } from '../map_layer/line.js';
|
5
5
|
import { AbstractPathElement } from './abstract_path.js';
|
6
|
-
import type {
|
6
|
+
import type { StateElementPolygon } from '../state/types.js';
|
7
7
|
export declare class PolygonElement extends AbstractPathElement {
|
8
8
|
readonly fillLayer: MapLayerFill;
|
9
9
|
readonly strokeLayer: MapLayerLine;
|
@@ -11,7 +11,7 @@ export declare class PolygonElement extends AbstractPathElement {
|
|
11
11
|
select(value: boolean): void;
|
12
12
|
getFeature(includeProperties?: boolean): GeoJSON.Feature<GeoJSON.Polygon>;
|
13
13
|
destroy(): void;
|
14
|
-
getState():
|
15
|
-
static fromState(manager: GeometryManager, state:
|
14
|
+
getState(): StateElementPolygon;
|
15
|
+
static fromState(manager: GeometryManager, state: StateElementPolygon): PolygonElement;
|
16
16
|
static fromGeoJSON(manager: GeometryManager, feature: GeoJSON.Feature<GeoJSON.Polygon>): PolygonElement;
|
17
17
|
}
|
@@ -1,8 +1,18 @@
|
|
1
1
|
import { type Writable } from 'svelte/store';
|
2
2
|
import type { AbstractElement } from './element/abstract.js';
|
3
|
+
import { MarkerElement } from './element/marker.js';
|
4
|
+
import { LineElement } from './element/line.js';
|
5
|
+
import { PolygonElement } from './element/polygon.js';
|
3
6
|
import { Cursor } from './cursor.js';
|
4
|
-
import type { StateObject } from './state/types.js';
|
5
7
|
import { SymbolLibrary } from './symbols.js';
|
8
|
+
import { StateManager } from './state/manager.js';
|
9
|
+
import type { StateRoot } from './state/types.js';
|
10
|
+
export type ExtendedGeoJSON = GeoJSON.FeatureCollection & {
|
11
|
+
map?: {
|
12
|
+
center: [number, number];
|
13
|
+
zoom: number;
|
14
|
+
};
|
15
|
+
};
|
6
16
|
export declare class GeometryManager {
|
7
17
|
readonly elements: Writable<AbstractElement[]>;
|
8
18
|
readonly map: maplibregl.Map;
|
@@ -10,19 +20,19 @@ export declare class GeometryManager {
|
|
10
20
|
readonly canvas: HTMLElement;
|
11
21
|
readonly cursor: Cursor;
|
12
22
|
readonly symbolLibrary: SymbolLibrary;
|
23
|
+
readonly state: StateManager;
|
13
24
|
private readonly selectionNodes;
|
14
25
|
constructor(map: maplibregl.Map);
|
15
26
|
selectElement(element: AbstractElement | undefined): void;
|
16
27
|
drawSelectionNodes(): void;
|
17
|
-
getState():
|
18
|
-
|
19
|
-
loadState(hash: string): Promise<void>;
|
28
|
+
getState(): StateRoot;
|
29
|
+
setState(state: StateRoot): void;
|
20
30
|
getElement(index: number): AbstractElement;
|
21
|
-
addNewMarker():
|
22
|
-
addNewLine():
|
23
|
-
addNewPolygon():
|
24
|
-
private
|
25
|
-
|
31
|
+
addNewMarker(): MarkerElement;
|
32
|
+
addNewLine(): LineElement;
|
33
|
+
addNewPolygon(): PolygonElement;
|
34
|
+
private appendElement;
|
35
|
+
removeElement(element: AbstractElement): void;
|
26
36
|
getGeoJSON(): GeoJSON.FeatureCollection;
|
27
|
-
addGeoJSON(geojson:
|
37
|
+
addGeoJSON(geojson: ExtendedGeoJSON): void;
|
28
38
|
}
|