isard 0.0.0-stage → 0.2.1
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/CHANGELOG.md +176 -0
- package/LICENSE +21 -0
- package/README.md +150 -2
- package/dist/basemap.worker.d.ts +76 -0
- package/dist/basemap.worker.js +4 -0
- package/dist/basemap.worker.js.map +13 -0
- package/dist/basemaps.d.ts +48 -0
- package/dist/basemaps.js +97 -0
- package/dist/basemaps.js.map +1 -0
- package/dist/color.d.ts +8 -0
- package/dist/color.js +98 -0
- package/dist/color.js.map +1 -0
- package/dist/controls.d.ts +43 -0
- package/dist/controls.js +115 -0
- package/dist/controls.js.map +1 -0
- package/dist/decoder.worker.js +6 -0
- package/dist/decoder.worker.js.map +12 -0
- package/dist/decoders.d.ts +27 -0
- package/dist/decoders.js +109 -0
- package/dist/decoders.js.map +1 -0
- package/dist/equirectangular.d.ts +35 -0
- package/dist/equirectangular.js +143 -0
- package/dist/equirectangular.js.map +1 -0
- package/dist/extrusions.d.ts +79 -0
- package/dist/extrusions.js +224 -0
- package/dist/extrusions.js.map +1 -0
- package/dist/features.d.ts +159 -0
- package/dist/features.js +387 -0
- package/dist/features.js.map +1 -0
- package/dist/geoplateforme.d.ts +35 -0
- package/dist/geoplateforme.js +56 -0
- package/dist/geoplateforme.js.map +1 -0
- package/dist/glyphs.d.ts +104 -0
- package/dist/glyphs.js +383 -0
- package/dist/glyphs.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/interaction.d.ts +53 -0
- package/dist/interaction.js +259 -0
- package/dist/interaction.js.map +1 -0
- package/dist/isard_bg.wasm +0 -0
- package/dist/isard_core_bg.wasm +0 -0
- package/dist/layers.d.ts +103 -0
- package/dist/layers.js +290 -0
- package/dist/layers.js.map +1 -0
- package/dist/loader.d.ts +30 -0
- package/dist/loader.js +102 -0
- package/dist/loader.js.map +1 -0
- package/dist/map.d.ts +211 -0
- package/dist/map.js +1222 -0
- package/dist/map.js.map +1 -0
- package/dist/mvt.d.ts +19 -0
- package/dist/mvt.js +231 -0
- package/dist/mvt.js.map +1 -0
- package/dist/overlay.d.ts +118 -0
- package/dist/overlay.js +334 -0
- package/dist/overlay.js.map +1 -0
- package/dist/protocol.d.ts +30 -0
- package/dist/protocol.js +2 -0
- package/dist/protocol.js.map +1 -0
- package/dist/style.d.ts +7 -0
- package/dist/style.js +130 -0
- package/dist/style.js.map +1 -0
- package/dist/symbols.d.ts +61 -0
- package/dist/symbols.js +238 -0
- package/dist/symbols.js.map +1 -0
- package/dist/terrain.d.ts +14 -0
- package/dist/terrain.js +56 -0
- package/dist/terrain.js.map +1 -0
- package/dist/types.d.ts +312 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/vectorstyle.d.ts +83 -0
- package/dist/vectorstyle.js +518 -0
- package/dist/vectorstyle.js.map +1 -0
- package/dist/vectortiles.d.ts +124 -0
- package/dist/vectortiles.js +523 -0
- package/dist/vectortiles.js.map +1 -0
- package/dist/wasm/isard.d.ts +612 -0
- package/dist/wasm/isard.js +2623 -0
- package/dist/wasm/isard_core.d.ts +469 -0
- package/dist/wasm/isard_core.js +2385 -0
- package/package.json +49 -4
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM overlays tied to a position: markers and popups. The map places them all in one pass after each frame it draws
|
|
3
|
+
* (camera moves, finer relief arriving), with a CSS transform from `map.project`: the browser only composites them,
|
|
4
|
+
* nothing is laid out again.
|
|
5
|
+
*/
|
|
6
|
+
import type { GeoMap } from './map.ts';
|
|
7
|
+
import type { LonLat, Point } from './types.ts';
|
|
8
|
+
/** Which part of the element sits on the position */
|
|
9
|
+
export type Anchor = 'center' | 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
10
|
+
export interface MarkerOptions {
|
|
11
|
+
/** The element to show (default: a round pin) */
|
|
12
|
+
element?: HTMLElement;
|
|
13
|
+
/** Which part of the element sits on the position (default 'center' with an element of your own, 'bottom' for the
|
|
14
|
+
* default pin) */
|
|
15
|
+
anchor?: Anchor;
|
|
16
|
+
/** Shift from the anchor, CSS pixels (default [0, 0]) */
|
|
17
|
+
offset?: Point;
|
|
18
|
+
/** The marker can be dragged over the map, on the relief (default false) */
|
|
19
|
+
draggable?: boolean;
|
|
20
|
+
/** Classes added to the element, space separated */
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface MarkerEvent {
|
|
24
|
+
target: Marker;
|
|
25
|
+
lonLat: LonLat;
|
|
26
|
+
}
|
|
27
|
+
export interface MarkerEvents {
|
|
28
|
+
dragstart: MarkerEvent;
|
|
29
|
+
drag: MarkerEvent;
|
|
30
|
+
dragend: MarkerEvent;
|
|
31
|
+
}
|
|
32
|
+
/** An element at a position on the map, optionally draggable */
|
|
33
|
+
export declare class Marker {
|
|
34
|
+
private readonly element;
|
|
35
|
+
private readonly anchor;
|
|
36
|
+
private readonly events;
|
|
37
|
+
private offset;
|
|
38
|
+
private draggable;
|
|
39
|
+
private lonLat;
|
|
40
|
+
private map;
|
|
41
|
+
private popup;
|
|
42
|
+
/** While pressed: the press point and the gap between the pointer and the marker's position */
|
|
43
|
+
private grab;
|
|
44
|
+
private dragging;
|
|
45
|
+
/** The click that ends a drag is not a click on the marker */
|
|
46
|
+
private swallowClick;
|
|
47
|
+
constructor(options?: MarkerOptions);
|
|
48
|
+
getElement(): HTMLElement;
|
|
49
|
+
getLonLat(): LonLat;
|
|
50
|
+
setLonLat(lonLat: LonLat): this;
|
|
51
|
+
setOffset(offset: Point): this;
|
|
52
|
+
setDraggable(draggable: boolean): this;
|
|
53
|
+
isDraggable(): boolean;
|
|
54
|
+
/** A popup that a click on the marker opens and closes, at the marker's position; give it an offset clearing the
|
|
55
|
+
* marker (with the default pin, [0, -34]) */
|
|
56
|
+
setPopup(popup: Popup | undefined): this;
|
|
57
|
+
getPopup(): Popup | undefined;
|
|
58
|
+
/** Opens the marker's popup, or closes it if open */
|
|
59
|
+
togglePopup(): this;
|
|
60
|
+
/** Listens to the drag of the marker; returns the function that stops listening */
|
|
61
|
+
on<K extends keyof MarkerEvents>(type: K, listener: (event: MarkerEvents[K]) => void): () => void;
|
|
62
|
+
addTo(map: GeoMap): this;
|
|
63
|
+
remove(): this;
|
|
64
|
+
private local;
|
|
65
|
+
private down;
|
|
66
|
+
private move;
|
|
67
|
+
private up;
|
|
68
|
+
private click;
|
|
69
|
+
}
|
|
70
|
+
export interface PopupOptions {
|
|
71
|
+
/** A × button in the corner (default true) */
|
|
72
|
+
closeButton?: boolean;
|
|
73
|
+
/** A click on the map elsewhere closes the popup (default true) */
|
|
74
|
+
closeOnClick?: boolean;
|
|
75
|
+
/** CSS max-width of the popup (default '240px') */
|
|
76
|
+
maxWidth?: string;
|
|
77
|
+
/** Classes added to the popup, space separated */
|
|
78
|
+
className?: string;
|
|
79
|
+
/** Which part of the popup sits on the position, its tip there (default 'bottom': the popup is above the point) */
|
|
80
|
+
anchor?: Anchor;
|
|
81
|
+
/** Shift from the anchor, CSS pixels (default [0, 0]) */
|
|
82
|
+
offset?: Point;
|
|
83
|
+
}
|
|
84
|
+
export interface PopupEvents {
|
|
85
|
+
open: {
|
|
86
|
+
target: Popup;
|
|
87
|
+
};
|
|
88
|
+
close: {
|
|
89
|
+
target: Popup;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** A box of content at a position, its tip pointing at it */
|
|
93
|
+
export declare class Popup {
|
|
94
|
+
private readonly container;
|
|
95
|
+
private readonly content;
|
|
96
|
+
private readonly closeButton;
|
|
97
|
+
private readonly anchor;
|
|
98
|
+
private readonly closeOnClick;
|
|
99
|
+
private readonly events;
|
|
100
|
+
private offset;
|
|
101
|
+
private lonLat;
|
|
102
|
+
private map;
|
|
103
|
+
private stopListening;
|
|
104
|
+
constructor(options?: PopupOptions);
|
|
105
|
+
getElement(): HTMLElement;
|
|
106
|
+
getLonLat(): LonLat;
|
|
107
|
+
setLonLat(lonLat: LonLat): this;
|
|
108
|
+
setOffset(offset: Point): this;
|
|
109
|
+
/** Content from an HTML string: only for trusted HTML (use `setText` for user or remote data) */
|
|
110
|
+
setHTML(html: string): this;
|
|
111
|
+
setText(text: string): this;
|
|
112
|
+
setDOMContent(node: Node): this;
|
|
113
|
+
isOpen(): boolean;
|
|
114
|
+
/** Listens to the popup opening or closing; returns the function that stops listening */
|
|
115
|
+
on<K extends keyof PopupEvents>(type: K, listener: (event: PopupEvents[K]) => void): () => void;
|
|
116
|
+
addTo(map: GeoMap): this;
|
|
117
|
+
remove(): this;
|
|
118
|
+
}
|
package/dist/overlay.js
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
const ANCHOR_TRANSLATE = {
|
|
2
|
+
center: 'translate(-50%, -50%)',
|
|
3
|
+
top: 'translate(-50%, 0)',
|
|
4
|
+
bottom: 'translate(-50%, -100%)',
|
|
5
|
+
left: 'translate(0, -50%)',
|
|
6
|
+
right: 'translate(-100%, -50%)',
|
|
7
|
+
'top-left': 'translate(0, 0)',
|
|
8
|
+
'top-right': 'translate(-100%, 0)',
|
|
9
|
+
'bottom-left': 'translate(0, -100%)',
|
|
10
|
+
'bottom-right': 'translate(-100%, -100%)',
|
|
11
|
+
};
|
|
12
|
+
/** Overlays further than this out of the canvas (CSS pixels) are hidden: no part of them can show, and huge
|
|
13
|
+
* transforms near the horizon would only cost the compositor */
|
|
14
|
+
const MARGIN = 500;
|
|
15
|
+
/** A press on a draggable marker that moves less than this (CSS pixels) is a click */
|
|
16
|
+
const DRAG_TOLERANCE = 3;
|
|
17
|
+
/** Typed listeners of an overlay */
|
|
18
|
+
class Emitter {
|
|
19
|
+
listeners = {};
|
|
20
|
+
on(type, listener) {
|
|
21
|
+
const set = this.listeners[type] ?? new Set();
|
|
22
|
+
this.listeners[type] = set;
|
|
23
|
+
set.add(listener);
|
|
24
|
+
return () => set.delete(listener);
|
|
25
|
+
}
|
|
26
|
+
emit(type, event) {
|
|
27
|
+
for (const listener of this.listeners[type] ?? [])
|
|
28
|
+
listener(event);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** Moves `element` so that its anchor sits on `lonLat`, or hides it when the position is out of sight */
|
|
32
|
+
function place(map, element, lonLat, anchor, offset, size) {
|
|
33
|
+
const point = map.project(lonLat);
|
|
34
|
+
const visible = point !== undefined &&
|
|
35
|
+
point[0] > -MARGIN &&
|
|
36
|
+
point[0] < size[0] + MARGIN &&
|
|
37
|
+
point[1] > -MARGIN &&
|
|
38
|
+
point[1] < size[1] + MARGIN;
|
|
39
|
+
if (!visible) {
|
|
40
|
+
element.style.display = 'none';
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
element.style.display = '';
|
|
44
|
+
// Whole pixels: a fractional translation blurs text and icons
|
|
45
|
+
const x = Math.round(point[0] + offset[0]);
|
|
46
|
+
const y = Math.round(point[1] + offset[1]);
|
|
47
|
+
element.style.transform = `translate(${x}px, ${y}px) ${ANCHOR_TRANSLATE[anchor]}`;
|
|
48
|
+
}
|
|
49
|
+
/** Round pin, its tip at the bottom: the default marker */
|
|
50
|
+
function pin() {
|
|
51
|
+
const element = document.createElement('div');
|
|
52
|
+
element.innerHTML =
|
|
53
|
+
'<svg class="isard-marker-pin" width="25" height="34" viewBox="0 0 25 34" aria-hidden="true">' +
|
|
54
|
+
'<path fill="currentColor" stroke="rgb(0 0 0 / 0.25)" d="M12.5 33.5C12.5 33.5 .5 20.6 .5 12.5a12 12 0 0 1 24 0' +
|
|
55
|
+
'c0 8.1-12 21-12 21z"/><circle cx="12.5" cy="12.5" r="4.5" fill="#fff"/></svg>';
|
|
56
|
+
return element;
|
|
57
|
+
}
|
|
58
|
+
/** An element at a position on the map, optionally draggable */
|
|
59
|
+
export class Marker {
|
|
60
|
+
element;
|
|
61
|
+
anchor;
|
|
62
|
+
events = new Emitter();
|
|
63
|
+
offset;
|
|
64
|
+
draggable;
|
|
65
|
+
lonLat = [0, 0];
|
|
66
|
+
map;
|
|
67
|
+
popup;
|
|
68
|
+
/** While pressed: the press point and the gap between the pointer and the marker's position */
|
|
69
|
+
grab;
|
|
70
|
+
dragging = false;
|
|
71
|
+
/** The click that ends a drag is not a click on the marker */
|
|
72
|
+
swallowClick = false;
|
|
73
|
+
constructor(options = {}) {
|
|
74
|
+
this.element = options.element ?? pin();
|
|
75
|
+
this.anchor = options.anchor ?? (options.element ? 'center' : 'bottom');
|
|
76
|
+
this.offset = options.offset ?? [0, 0];
|
|
77
|
+
this.draggable = options.draggable ?? false;
|
|
78
|
+
this.element.classList.add('isard-marker');
|
|
79
|
+
if (options.className)
|
|
80
|
+
this.element.classList.add(...options.className.split(/\s+/).filter(Boolean));
|
|
81
|
+
this.element.classList.toggle('isard-marker-draggable', this.draggable);
|
|
82
|
+
this.element.addEventListener('pointerdown', (e) => this.down(e));
|
|
83
|
+
this.element.addEventListener('pointermove', (e) => this.move(e));
|
|
84
|
+
this.element.addEventListener('pointerup', (e) => this.up(e));
|
|
85
|
+
this.element.addEventListener('pointercancel', (e) => this.up(e));
|
|
86
|
+
this.element.addEventListener('click', (e) => this.click(e), { capture: true });
|
|
87
|
+
}
|
|
88
|
+
getElement() {
|
|
89
|
+
return this.element;
|
|
90
|
+
}
|
|
91
|
+
getLonLat() {
|
|
92
|
+
return [...this.lonLat];
|
|
93
|
+
}
|
|
94
|
+
setLonLat(lonLat) {
|
|
95
|
+
this.lonLat = [lonLat[0], lonLat[1]];
|
|
96
|
+
this.map?.positionOverlay(this);
|
|
97
|
+
// An open popup of the marker goes with it
|
|
98
|
+
if (this.popup?.isOpen())
|
|
99
|
+
this.popup.setLonLat(this.lonLat);
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
setOffset(offset) {
|
|
103
|
+
this.offset = [offset[0], offset[1]];
|
|
104
|
+
this.map?.positionOverlay(this);
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
setDraggable(draggable) {
|
|
108
|
+
this.draggable = draggable;
|
|
109
|
+
this.element.classList.toggle('isard-marker-draggable', draggable);
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
isDraggable() {
|
|
113
|
+
return this.draggable;
|
|
114
|
+
}
|
|
115
|
+
/** A popup that a click on the marker opens and closes, at the marker's position; give it an offset clearing the
|
|
116
|
+
* marker (with the default pin, [0, -34]) */
|
|
117
|
+
setPopup(popup) {
|
|
118
|
+
this.popup?.remove();
|
|
119
|
+
this.popup = popup;
|
|
120
|
+
return this;
|
|
121
|
+
}
|
|
122
|
+
getPopup() {
|
|
123
|
+
return this.popup;
|
|
124
|
+
}
|
|
125
|
+
/** Opens the marker's popup, or closes it if open */
|
|
126
|
+
togglePopup() {
|
|
127
|
+
if (!this.popup || !this.map)
|
|
128
|
+
return this;
|
|
129
|
+
if (this.popup.isOpen())
|
|
130
|
+
this.popup.remove();
|
|
131
|
+
else
|
|
132
|
+
this.popup.setLonLat(this.lonLat).addTo(this.map);
|
|
133
|
+
return this;
|
|
134
|
+
}
|
|
135
|
+
/** Listens to the drag of the marker; returns the function that stops listening */
|
|
136
|
+
on(type, listener) {
|
|
137
|
+
return this.events.on(type, listener);
|
|
138
|
+
}
|
|
139
|
+
addTo(map) {
|
|
140
|
+
if (this.map === map)
|
|
141
|
+
return this;
|
|
142
|
+
this.remove();
|
|
143
|
+
this.map = map;
|
|
144
|
+
map.attachOverlay(this, this.element);
|
|
145
|
+
return this;
|
|
146
|
+
}
|
|
147
|
+
remove() {
|
|
148
|
+
this.popup?.remove();
|
|
149
|
+
this.map?.detachOverlay(this, this.element);
|
|
150
|
+
this.map = undefined;
|
|
151
|
+
this.grab = undefined;
|
|
152
|
+
this.dragging = false;
|
|
153
|
+
this.element.classList.remove('isard-marker-dragging');
|
|
154
|
+
return this;
|
|
155
|
+
}
|
|
156
|
+
/** @internal */
|
|
157
|
+
position(size) {
|
|
158
|
+
if (this.map)
|
|
159
|
+
place(this.map, this.element, this.lonLat, this.anchor, this.offset, size);
|
|
160
|
+
}
|
|
161
|
+
local(e) {
|
|
162
|
+
const rect = this.map?.getCanvas().getBoundingClientRect();
|
|
163
|
+
return rect && [e.clientX - rect.left, e.clientY - rect.top];
|
|
164
|
+
}
|
|
165
|
+
down(e) {
|
|
166
|
+
this.swallowClick = false;
|
|
167
|
+
if (!this.draggable || !this.map || e.button !== 0)
|
|
168
|
+
return;
|
|
169
|
+
const point = this.map.project(this.lonLat);
|
|
170
|
+
const at = this.local(e);
|
|
171
|
+
if (!point || !at)
|
|
172
|
+
return;
|
|
173
|
+
// The map must not start panning under the marker
|
|
174
|
+
e.stopPropagation();
|
|
175
|
+
e.preventDefault();
|
|
176
|
+
this.element.setPointerCapture(e.pointerId);
|
|
177
|
+
// The grabbed spot of the marker stays under the pointer, wherever the element was pressed
|
|
178
|
+
this.grab = { start: at, gap: [at[0] - point[0], at[1] - point[1]] };
|
|
179
|
+
this.dragging = false;
|
|
180
|
+
}
|
|
181
|
+
move(e) {
|
|
182
|
+
const at = this.local(e);
|
|
183
|
+
if (!this.grab || !this.map || !at)
|
|
184
|
+
return;
|
|
185
|
+
e.stopPropagation();
|
|
186
|
+
const { start, gap } = this.grab;
|
|
187
|
+
if (!this.dragging && Math.hypot(at[0] - start[0], at[1] - start[1]) < DRAG_TOLERANCE)
|
|
188
|
+
return;
|
|
189
|
+
// On the relief: the ground under the point, read back from the picking pass
|
|
190
|
+
const lonLat = this.map.unproject([at[0] - gap[0], at[1] - gap[1]]);
|
|
191
|
+
if (!lonLat)
|
|
192
|
+
return;
|
|
193
|
+
if (!this.dragging) {
|
|
194
|
+
this.dragging = true;
|
|
195
|
+
this.element.classList.add('isard-marker-dragging');
|
|
196
|
+
this.events.emit('dragstart', { target: this, lonLat: this.getLonLat() });
|
|
197
|
+
}
|
|
198
|
+
this.setLonLat(lonLat);
|
|
199
|
+
this.events.emit('drag', { target: this, lonLat: this.getLonLat() });
|
|
200
|
+
}
|
|
201
|
+
up(e) {
|
|
202
|
+
if (!this.grab)
|
|
203
|
+
return;
|
|
204
|
+
e.stopPropagation();
|
|
205
|
+
this.grab = undefined;
|
|
206
|
+
if (this.element.hasPointerCapture(e.pointerId))
|
|
207
|
+
this.element.releasePointerCapture(e.pointerId);
|
|
208
|
+
if (!this.dragging)
|
|
209
|
+
return;
|
|
210
|
+
this.dragging = false;
|
|
211
|
+
this.swallowClick = true;
|
|
212
|
+
this.element.classList.remove('isard-marker-dragging');
|
|
213
|
+
this.events.emit('dragend', { target: this, lonLat: this.getLonLat() });
|
|
214
|
+
}
|
|
215
|
+
click(e) {
|
|
216
|
+
if (this.swallowClick) {
|
|
217
|
+
this.swallowClick = false;
|
|
218
|
+
e.stopImmediatePropagation();
|
|
219
|
+
e.preventDefault();
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
if (this.popup)
|
|
223
|
+
this.togglePopup();
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/** A box of content at a position, its tip pointing at it */
|
|
227
|
+
export class Popup {
|
|
228
|
+
container;
|
|
229
|
+
content;
|
|
230
|
+
closeButton;
|
|
231
|
+
anchor;
|
|
232
|
+
closeOnClick;
|
|
233
|
+
events = new Emitter();
|
|
234
|
+
offset;
|
|
235
|
+
lonLat = [0, 0];
|
|
236
|
+
map;
|
|
237
|
+
stopListening;
|
|
238
|
+
constructor(options = {}) {
|
|
239
|
+
this.anchor = options.anchor ?? 'bottom';
|
|
240
|
+
this.offset = options.offset ?? [0, 0];
|
|
241
|
+
this.closeOnClick = options.closeOnClick ?? true;
|
|
242
|
+
this.container = document.createElement('div');
|
|
243
|
+
this.container.className = `isard-popup isard-popup-anchor-${this.anchor}`;
|
|
244
|
+
if (options.className)
|
|
245
|
+
this.container.classList.add(...options.className.split(/\s+/).filter(Boolean));
|
|
246
|
+
this.container.style.maxWidth = options.maxWidth ?? '240px';
|
|
247
|
+
const tip = document.createElement('div');
|
|
248
|
+
tip.className = 'isard-popup-tip';
|
|
249
|
+
this.content = document.createElement('div');
|
|
250
|
+
this.content.className = 'isard-popup-content';
|
|
251
|
+
if (options.closeButton ?? true) {
|
|
252
|
+
this.container.classList.add('isard-popup-has-close');
|
|
253
|
+
this.closeButton = document.createElement('button');
|
|
254
|
+
this.closeButton.type = 'button';
|
|
255
|
+
this.closeButton.className = 'isard-popup-close';
|
|
256
|
+
this.closeButton.setAttribute('aria-label', 'Close popup');
|
|
257
|
+
this.closeButton.textContent = '×';
|
|
258
|
+
this.closeButton.addEventListener('click', () => this.remove());
|
|
259
|
+
this.content.append(this.closeButton);
|
|
260
|
+
}
|
|
261
|
+
this.container.append(tip, this.content);
|
|
262
|
+
}
|
|
263
|
+
getElement() {
|
|
264
|
+
return this.container;
|
|
265
|
+
}
|
|
266
|
+
getLonLat() {
|
|
267
|
+
return [...this.lonLat];
|
|
268
|
+
}
|
|
269
|
+
setLonLat(lonLat) {
|
|
270
|
+
this.lonLat = [lonLat[0], lonLat[1]];
|
|
271
|
+
this.map?.positionOverlay(this);
|
|
272
|
+
return this;
|
|
273
|
+
}
|
|
274
|
+
setOffset(offset) {
|
|
275
|
+
this.offset = [offset[0], offset[1]];
|
|
276
|
+
this.map?.positionOverlay(this);
|
|
277
|
+
return this;
|
|
278
|
+
}
|
|
279
|
+
/** Content from an HTML string: only for trusted HTML (use `setText` for user or remote data) */
|
|
280
|
+
setHTML(html) {
|
|
281
|
+
const template = document.createElement('template');
|
|
282
|
+
template.innerHTML = html;
|
|
283
|
+
return this.setDOMContent(template.content);
|
|
284
|
+
}
|
|
285
|
+
setText(text) {
|
|
286
|
+
return this.setDOMContent(document.createTextNode(text));
|
|
287
|
+
}
|
|
288
|
+
setDOMContent(node) {
|
|
289
|
+
this.content.replaceChildren(node);
|
|
290
|
+
if (this.closeButton)
|
|
291
|
+
this.content.append(this.closeButton);
|
|
292
|
+
this.map?.positionOverlay(this);
|
|
293
|
+
return this;
|
|
294
|
+
}
|
|
295
|
+
isOpen() {
|
|
296
|
+
return this.map !== undefined;
|
|
297
|
+
}
|
|
298
|
+
/** Listens to the popup opening or closing; returns the function that stops listening */
|
|
299
|
+
on(type, listener) {
|
|
300
|
+
return this.events.on(type, listener);
|
|
301
|
+
}
|
|
302
|
+
addTo(map) {
|
|
303
|
+
if (this.map === map)
|
|
304
|
+
return this;
|
|
305
|
+
this.remove();
|
|
306
|
+
this.map = map;
|
|
307
|
+
map.attachOverlay(this, this.container);
|
|
308
|
+
if (this.closeOnClick) {
|
|
309
|
+
// From the next task on: a popup opened by a map click must not be closed by that same click
|
|
310
|
+
queueMicrotask(() => {
|
|
311
|
+
if (this.map === map && !this.stopListening)
|
|
312
|
+
this.stopListening = map.on('click', () => this.remove());
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
this.events.emit('open', { target: this });
|
|
316
|
+
return this;
|
|
317
|
+
}
|
|
318
|
+
remove() {
|
|
319
|
+
if (!this.map)
|
|
320
|
+
return this;
|
|
321
|
+
this.stopListening?.();
|
|
322
|
+
this.stopListening = undefined;
|
|
323
|
+
this.map.detachOverlay(this, this.container);
|
|
324
|
+
this.map = undefined;
|
|
325
|
+
this.events.emit('close', { target: this });
|
|
326
|
+
return this;
|
|
327
|
+
}
|
|
328
|
+
/** @internal */
|
|
329
|
+
position(size) {
|
|
330
|
+
if (this.map)
|
|
331
|
+
place(this.map, this.container, this.lonLat, this.anchor, this.offset, size);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
//# sourceMappingURL=overlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay.js","sourceRoot":"","sources":["../src/overlay.ts"],"names":[],"mappings":"AAoBA,MAAM,gBAAgB,GAA2B;IAC/C,MAAM,EAAE,uBAAuB;IAC/B,GAAG,EAAE,oBAAoB;IACzB,MAAM,EAAE,wBAAwB;IAChC,IAAI,EAAE,oBAAoB;IAC1B,KAAK,EAAE,wBAAwB;IAC/B,UAAU,EAAE,iBAAiB;IAC7B,WAAW,EAAE,qBAAqB;IAClC,aAAa,EAAE,qBAAqB;IACpC,cAA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;QACL,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,GAAG;YAAE,OAAO,IAAI,CAAC;QAC3B,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;QAC/B,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAC7C,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC;QACrB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gBAAgB;IAChB,QAAQ,CAAC,IAAW;QAClB,IAAI,IAAI,CAAC,GAAG;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC7F,CAAC;CACF","sourcesContent":["/**\n * DOM overlays tied to a position: markers and popups. The map places them all in one pass after each frame it draws\n * (camera moves, finer relief arriving), with a CSS transform from `map.project`: the browser only composites them,\n * nothing is laid out again.\n */\nimport type { GeoMap } from './map.ts';\nimport type { LonLat, Point } from './types.ts';\n\n/** Which part of the element sits on the position */\nexport type Anchor =\n | 'center'\n | 'top'\n | 'bottom'\n | 'left'\n | 'right'\n | 'top-left'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-right';\n\nconst ANCHOR_TRANSLATE: Record<Anchor, string> = {\n center: 'translate(-50%, -50%)',\n top: 'translate(-50%, 0)',\n bottom: 'translate(-50%, -100%)',\n left: 'translate(0, -50%)',\n right: 'translate(-100%, -50%)',\n 'top-left': 'translate(0, 0)',\n 'top-right': 'translate(-100%, 0)',\n 'bottom-left': 'translate(0, -100%)',\n 'bottom-right': 'translate(-100%, -100%)',\n};\n\n/** Overlays further than this out of the canvas (CSS pixels) are hidden: no part of them can show, and huge\n * transforms near the horizon would only cost the compositor */\nconst MARGIN = 500;\n/** A press on a draggable marker that moves less than this (CSS pixels) is a click */\nconst DRAG_TOLERANCE = 3;\n\n/** @internal What the map places after each frame */\nexport interface Positioned {\n /** Places the overlay for the current camera; `size` is the canvas size in CSS pixels */\n position(size: Point): void;\n}\n\n/** Typed listeners of an overlay */\nclass Emitter<E> {\n private readonly listeners: { [K in keyof E]?: Set<(event: E[K]) => void> } = {};\n\n on<K extends keyof E>(type: K, listener: (event: E[K]) => void): () => void {\n const set = this.listeners[type] ?? new Set();\n this.listeners[type] = set;\n set.add(listener);\n return () => set.delete(listener);\n }\n\n emit<K extends keyof E>(type: K, event: E[K]): void {\n for (const listener of this.listeners[type] ?? []) listener(event);\n }\n}\n\n/** Moves `element` so that its anchor sits on `lonLat`, or hides it when the position is out of sight */\nfunction place(map: GeoMap, element: HTMLElement, lonLat: LonLat, anchor: Anchor, offset: Point, size: Point): void {\n const point = map.project(lonLat);\n const visible =\n point !== undefined &&\n point[0] > -MARGIN &&\n point[0] < size[0] + MARGIN &&\n point[1] > -MARGIN &&\n point[1] < size[1] + MARGIN;\n if (!visible) {\n element.style.display = 'none';\n return;\n }\n element.style.display = '';\n // Whole pixels: a fractional translation blurs text and icons\n const x = Math.round(point[0] + offset[0]);\n const y = Math.round(point[1] + offset[1]);\n element.style.transform = `translate(${x}px, ${y}px) ${ANCHOR_TRANSLATE[anchor]}`;\n}\n\n/** Round pin, its tip at the bottom: the default marker */\nfunction pin(): HTMLElement {\n const element = document.createElement('div');\n element.innerHTML =\n '<svg class=\"isard-marker-pin\" width=\"25\" height=\"34\" viewBox=\"0 0 25 34\" aria-hidden=\"true\">' +\n '<path fill=\"currentColor\" stroke=\"rgb(0 0 0 / 0.25)\" d=\"M12.5 33.5C12.5 33.5 .5 20.6 .5 12.5a12 12 0 0 1 24 0' +\n 'c0 8.1-12 21-12 21z\"/><circle cx=\"12.5\" cy=\"12.5\" r=\"4.5\" fill=\"#fff\"/></svg>';\n return element;\n}\n\nexport interface MarkerOptions {\n /** The element to show (default: a round pin) */\n element?: HTMLElement;\n /** Which part of the element sits on the position (default 'center' with an element of your own, 'bottom' for the\n * default pin) */\n anchor?: Anchor;\n /** Shift from the anchor, CSS pixels (default [0, 0]) */\n offset?: Point;\n /** The marker can be dragged over the map, on the relief (default false) */\n draggable?: boolean;\n /** Classes added to the element, space separated */\n className?: string;\n}\n\nexport interface MarkerEvent {\n target: Marker;\n lonLat: LonLat;\n}\n\nexport interface MarkerEvents {\n dragstart: MarkerEvent;\n drag: MarkerEvent;\n dragend: MarkerEvent;\n}\n\n/** An element at a position on the map, optionally draggable */\nexport class Marker {\n private readonly element: HTMLElement;\n private readonly anchor: Anchor;\n private readonly events = new Emitter<MarkerEvents>();\n private offset: Point;\n private draggable: boolean;\n private lonLat: LonLat = [0, 0];\n private map: GeoMap | undefined;\n private popup: Popup | undefined;\n /** While pressed: the press point and the gap between the pointer and the marker's position */\n private grab: { start: Point; gap: Point } | undefined;\n private dragging = false;\n /** The click that ends a drag is not a click on the marker */\n private swallowClick = false;\n\n constructor(options: MarkerOptions = {}) {\n this.element = options.element ?? pin();\n this.anchor = options.anchor ?? (options.element ? 'center' : 'bottom');\n this.offset = options.offset ?? [0, 0];\n this.draggable = options.draggable ?? false;\n this.element.classList.add('isard-marker');\n if (options.className) this.element.classList.add(...options.className.split(/\\s+/).filter(Boolean));\n this.element.classList.toggle('isard-marker-draggable', this.draggable);\n this.element.addEventListener('pointerdown', (e) => this.down(e));\n this.element.addEventListener('pointermove', (e) => this.move(e));\n this.element.addEventListener('pointerup', (e) => this.up(e));\n this.element.addEventListener('pointercancel', (e) => this.up(e));\n this.element.addEventListener('click', (e) => this.click(e), { capture: true });\n }\n\n getElement(): HTMLElement {\n return this.element;\n }\n\n getLonLat(): LonLat {\n return [...this.lonLat];\n }\n\n setLonLat(lonLat: LonLat): this {\n this.lonLat = [lonLat[0], lonLat[1]];\n this.map?.positionOverlay(this);\n // An open popup of the marker goes with it\n if (this.popup?.isOpen()) this.popup.setLonLat(this.lonLat);\n return this;\n }\n\n setOffset(offset: Point): this {\n this.offset = [offset[0], offset[1]];\n this.map?.positionOverlay(this);\n return this;\n }\n\n setDraggable(draggable: boolean): this {\n this.draggable = draggable;\n this.element.classList.toggle('isard-marker-draggable', draggable);\n return this;\n }\n\n isDraggable(): boolean {\n return this.draggable;\n }\n\n /** A popup that a click on the marker opens and closes, at the marker's position; give it an offset clearing the\n * marker (with the default pin, [0, -34]) */\n setPopup(popup: Popup | undefined): this {\n this.popup?.remove();\n this.popup = popup;\n return this;\n }\n\n getPopup(): Popup | undefined {\n return this.popup;\n }\n\n /** Opens the marker's popup, or closes it if open */\n togglePopup(): this {\n if (!this.popup || !this.map) return this;\n if (this.popup.isOpen()) this.popup.remove();\n else this.popup.setLonLat(this.lonLat).addTo(this.map);\n return this;\n }\n\n /** Listens to the drag of the marker; returns the function that stops listening */\n on<K extends keyof MarkerEvents>(type: K, listener: (event: MarkerEvents[K]) => void): () => void {\n return this.events.on(type, listener);\n }\n\n addTo(map: GeoMap): this {\n if (this.map === map) return this;\n this.remove();\n this.map = map;\n map.attachOverlay(this, this.element);\n return this;\n }\n\n remove(): this {\n this.popup?.remove();\n this.map?.detachOverlay(this, this.element);\n this.map = undefined;\n this.grab = undefined;\n this.dragging = false;\n this.element.classList.remove('isard-marker-dragging');\n return this;\n }\n\n /** @internal */\n position(size: Point): void {\n if (this.map) place(this.map, this.element, this.lonLat, this.anchor, this.offset, size);\n }\n\n private local(e: PointerEvent): Point | undefined {\n const rect = this.map?.getCanvas().getBoundingClientRect();\n return rect && [e.clientX - rect.left, e.clientY - rect.top];\n }\n\n private down(e: PointerEvent): void {\n this.swallowClick = false;\n if (!this.draggable || !this.map || e.button !== 0) return;\n const point = this.map.project(this.lonLat);\n const at = this.local(e);\n if (!point || !at) return;\n // The map must not start panning under the marker\n e.stopPropagation();\n e.preventDefault();\n this.element.setPointerCapture(e.pointerId);\n // The grabbed spot of the marker stays under the pointer, wherever the element was pressed\n this.grab = { start: at, gap: [at[0] - point[0], at[1] - point[1]] };\n this.dragging = false;\n }\n\n private move(e: PointerEvent): void {\n const at = this.local(e);\n if (!this.grab || !this.map || !at) return;\n e.stopPropagation();\n const { start, gap } = this.grab;\n if (!this.dragging && Math.hypot(at[0] - start[0], at[1] - start[1]) < DRAG_TOLERANCE) return;\n // On the relief: the ground under the point, read back from the picking pass\n const lonLat = this.map.unproject([at[0] - gap[0], at[1] - gap[1]]);\n if (!lonLat) return;\n if (!this.dragging) {\n this.dragging = true;\n this.element.classList.add('isard-marker-dragging');\n this.events.emit('dragstart', { target: this, lonLat: this.getLonLat() });\n }\n this.setLonLat(lonLat);\n this.events.emit('drag', { target: this, lonLat: this.getLonLat() });\n }\n\n private up(e: PointerEvent): void {\n if (!this.grab) return;\n e.stopPropagation();\n this.grab = undefined;\n if (this.element.hasPointerCapture(e.pointerId)) this.element.releasePointerCapture(e.pointerId);\n if (!this.dragging) return;\n this.dragging = false;\n this.swallowClick = true;\n this.element.classList.remove('isard-marker-dragging');\n this.events.emit('dragend', { target: this, lonLat: this.getLonLat() });\n }\n\n private click(e: MouseEvent): void {\n if (this.swallowClick) {\n this.swallowClick = false;\n e.stopImmediatePropagation();\n e.preventDefault();\n return;\n }\n if (this.popup) this.togglePopup();\n }\n}\n\nexport interface PopupOptions {\n /** A × button in the corner (default true) */\n closeButton?: boolean;\n /** A click on the map elsewhere closes the popup (default true) */\n closeOnClick?: boolean;\n /** CSS max-width of the popup (default '240px') */\n maxWidth?: string;\n /** Classes added to the popup, space separated */\n className?: string;\n /** Which part of the popup sits on the position, its tip there (default 'bottom': the popup is above the point) */\n anchor?: Anchor;\n /** Shift from the anchor, CSS pixels (default [0, 0]) */\n offset?: Point;\n}\n\nexport interface PopupEvents {\n open: { target: Popup };\n close: { target: Popup };\n}\n\n/** A box of content at a position, its tip pointing at it */\nexport class Popup {\n private readonly container: HTMLElement;\n private readonly content: HTMLElement;\n private readonly closeButton: HTMLButtonElement | undefined;\n private readonly anchor: Anchor;\n private readonly closeOnClick: boolean;\n private readonly events = new Emitter<PopupEvents>();\n private offset: Point;\n private lonLat: LonLat = [0, 0];\n private map: GeoMap | undefined;\n private stopListening: (() => void) | undefined;\n\n constructor(options: PopupOptions = {}) {\n this.anchor = options.anchor ?? 'bottom';\n this.offset = options.offset ?? [0, 0];\n this.closeOnClick = options.closeOnClick ?? true;\n this.container = document.createElement('div');\n this.container.className = `isard-popup isard-popup-anchor-${this.anchor}`;\n if (options.className) this.container.classList.add(...options.className.split(/\\s+/).filter(Boolean));\n this.container.style.maxWidth = options.maxWidth ?? '240px';\n const tip = document.createElement('div');\n tip.className = 'isard-popup-tip';\n this.content = document.createElement('div');\n this.content.className = 'isard-popup-content';\n if (options.closeButton ?? true) {\n this.container.classList.add('isard-popup-has-close');\n this.closeButton = document.createElement('button');\n this.closeButton.type = 'button';\n this.closeButton.className = 'isard-popup-close';\n this.closeButton.setAttribute('aria-label', 'Close popup');\n this.closeButton.textContent = '×';\n this.closeButton.addEventListener('click', () => this.remove());\n this.content.append(this.closeButton);\n }\n this.container.append(tip, this.content);\n }\n\n getElement(): HTMLElement {\n return this.container;\n }\n\n getLonLat(): LonLat {\n return [...this.lonLat];\n }\n\n setLonLat(lonLat: LonLat): this {\n this.lonLat = [lonLat[0], lonLat[1]];\n this.map?.positionOverlay(this);\n return this;\n }\n\n setOffset(offset: Point): this {\n this.offset = [offset[0], offset[1]];\n this.map?.positionOverlay(this);\n return this;\n }\n\n /** Content from an HTML string: only for trusted HTML (use `setText` for user or remote data) */\n setHTML(html: string): this {\n const template = document.createElement('template');\n template.innerHTML = html;\n return this.setDOMContent(template.content);\n }\n\n setText(text: string): this {\n return this.setDOMContent(document.createTextNode(text));\n }\n\n setDOMContent(node: Node): this {\n this.content.replaceChildren(node);\n if (this.closeButton) this.content.append(this.closeButton);\n this.map?.positionOverlay(this);\n return this;\n }\n\n isOpen(): boolean {\n return this.map !== undefined;\n }\n\n /** Listens to the popup opening or closing; returns the function that stops listening */\n on<K extends keyof PopupEvents>(type: K, listener: (event: PopupEvents[K]) => void): () => void {\n return this.events.on(type, listener);\n }\n\n addTo(map: GeoMap): this {\n if (this.map === map) return this;\n this.remove();\n this.map = map;\n map.attachOverlay(this, this.container);\n if (this.closeOnClick) {\n // From the next task on: a popup opened by a map click must not be closed by that same click\n queueMicrotask(() => {\n if (this.map === map && !this.stopListening) this.stopListening = map.on('click', () => this.remove());\n });\n }\n this.events.emit('open', { target: this });\n return this;\n }\n\n remove(): this {\n if (!this.map) return this;\n this.stopListening?.();\n this.stopListening = undefined;\n this.map.detachOverlay(this, this.container);\n this.map = undefined;\n this.events.emit('close', { target: this });\n return this;\n }\n\n /** @internal */\n position(size: Point): void {\n if (this.map) place(this.map, this.container, this.lonLat, this.anchor, this.offset, size);\n }\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Messages between the main thread and the decoding workers */
|
|
2
|
+
import type { DecoderUrls } from './decoders.ts';
|
|
3
|
+
import type { DecodedTile, TextureFormats } from './wasm/isard.js';
|
|
4
|
+
export type WorkerRequest = {
|
|
5
|
+
type: 'init';
|
|
6
|
+
module: WebAssembly.Module;
|
|
7
|
+
decoders: DecoderUrls;
|
|
8
|
+
formats: TextureFormats;
|
|
9
|
+
} | {
|
|
10
|
+
type: 'load';
|
|
11
|
+
id: number;
|
|
12
|
+
url: string;
|
|
13
|
+
transform: Float64Array;
|
|
14
|
+
yUp: boolean;
|
|
15
|
+
reload: boolean;
|
|
16
|
+
priority?: 'high' | 'low';
|
|
17
|
+
} | {
|
|
18
|
+
type: 'abort';
|
|
19
|
+
id: number;
|
|
20
|
+
};
|
|
21
|
+
export type WorkerReply = {
|
|
22
|
+
type: 'tile';
|
|
23
|
+
id: number;
|
|
24
|
+
tile: DecodedTile;
|
|
25
|
+
} | {
|
|
26
|
+
type: 'error';
|
|
27
|
+
id: number;
|
|
28
|
+
error: string;
|
|
29
|
+
aborted: boolean;
|
|
30
|
+
};
|
package/dist/protocol.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"","sourcesContent":["/** Messages between the main thread and the decoding workers */\nimport type { DecoderUrls } from './decoders.ts';\nimport type { DecodedTile, TextureFormats } from './wasm/isard.js';\n\nexport type WorkerRequest =\n | { type: 'init'; module: WebAssembly.Module; decoders: DecoderUrls; formats: TextureFormats }\n | {\n type: 'load';\n id: number;\n url: string;\n transform: Float64Array;\n yUp: boolean;\n reload: boolean;\n priority?: 'high' | 'low';\n }\n | { type: 'abort'; id: number };\n\nexport type WorkerReply =\n | { type: 'tile'; id: number; tile: DecodedTile }\n | { type: 'error'; id: number; error: string; aborted: boolean };\n"]}
|
package/dist/style.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Styles of the DOM overlays (markers, popups, controls), injected once per document so the package needs no CSS
|
|
3
|
+
* file. Colors are custom properties, defaults on the root with no specificity: an application restyles them on any
|
|
4
|
+
* element around the map (its container's class may be replaced by a framework: nothing depends on it).
|
|
5
|
+
*/
|
|
6
|
+
/** Adds the overlay styles to a document, once; first in the head so application rules win at equal specificity */
|
|
7
|
+
export declare function injectStyle(doc: Document): void;
|