@fieldia/map 0.17.0 → 0.19.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/README.md +75 -10
- package/package.json +4 -4
- package/src/index.d.mts +5 -0
- package/src/index.d.ts +5 -0
- package/src/index.js +4 -1
- package/src/index.js.map +1 -1
- package/src/index.mjs +2 -0
- package/src/index.mjs.map +1 -1
- package/src/lib/address-labels.d.mts +21 -0
- package/src/lib/address-labels.d.ts +21 -0
- package/src/lib/address-labels.js +16 -0
- package/src/lib/address-labels.js.map +1 -0
- package/src/lib/address-labels.mjs +12 -0
- package/src/lib/address-labels.mjs.map +1 -0
- package/src/lib/address-line.d.mts +2 -0
- package/src/lib/address-line.d.ts +2 -0
- package/src/lib/address-line.js +34 -0
- package/src/lib/address-line.js.map +1 -0
- package/src/lib/address-line.mjs +31 -0
- package/src/lib/address-line.mjs.map +1 -0
- package/src/lib/address-parts.d.mts +28 -0
- package/src/lib/address-parts.d.ts +28 -0
- package/src/lib/address-parts.js +47 -0
- package/src/lib/address-parts.js.map +1 -0
- package/src/lib/address-parts.mjs +38 -0
- package/src/lib/address-parts.mjs.map +1 -0
- package/src/lib/address-search.d.mts +21 -0
- package/src/lib/address-search.d.ts +21 -0
- package/src/lib/address-search.js +52 -0
- package/src/lib/address-search.js.map +1 -0
- package/src/lib/address-search.mjs +49 -0
- package/src/lib/address-search.mjs.map +1 -0
- package/src/lib/address-suggest.d.mts +18 -0
- package/src/lib/address-suggest.d.ts +18 -0
- package/src/lib/address-suggest.js +140 -0
- package/src/lib/address-suggest.js.map +1 -0
- package/src/lib/address-suggest.mjs +137 -0
- package/src/lib/address-suggest.mjs.map +1 -0
- package/src/lib/area-count.d.mts +47 -0
- package/src/lib/area-count.d.ts +47 -0
- package/src/lib/area-count.js +123 -0
- package/src/lib/area-count.js.map +1 -0
- package/src/lib/area-count.mjs +116 -0
- package/src/lib/area-count.mjs.map +1 -0
- package/src/lib/card.d.mts +16 -6
- package/src/lib/card.d.ts +16 -6
- package/src/lib/card.js +71 -14
- package/src/lib/card.js.map +1 -1
- package/src/lib/card.mjs +70 -14
- package/src/lib/card.mjs.map +1 -1
- package/src/lib/cluster.d.mts +6 -1
- package/src/lib/cluster.d.ts +6 -1
- package/src/lib/cluster.js +11 -5
- package/src/lib/cluster.js.map +1 -1
- package/src/lib/cluster.mjs +11 -5
- package/src/lib/cluster.mjs.map +1 -1
- package/src/lib/embed.d.mts +86 -0
- package/src/lib/embed.d.ts +86 -0
- package/src/lib/embed.js +96 -0
- package/src/lib/embed.js.map +1 -0
- package/src/lib/embed.mjs +93 -0
- package/src/lib/embed.mjs.map +1 -0
- package/src/lib/form-map.d.mts +2 -1
- package/src/lib/form-map.d.ts +2 -1
- package/src/lib/form-map.js +159 -20
- package/src/lib/form-map.js.map +1 -1
- package/src/lib/form-map.mjs +161 -22
- package/src/lib/form-map.mjs.map +1 -1
- package/src/lib/kinds.d.mts +6 -4
- package/src/lib/kinds.d.ts +6 -4
- package/src/lib/kinds.js +49 -2
- package/src/lib/kinds.js.map +1 -1
- package/src/lib/kinds.mjs +49 -2
- package/src/lib/kinds.mjs.map +1 -1
- package/src/lib/labels.d.mts +5 -0
- package/src/lib/labels.d.ts +5 -0
- package/src/lib/labels.js +12 -4
- package/src/lib/labels.js.map +1 -1
- package/src/lib/labels.mjs +12 -4
- package/src/lib/labels.mjs.map +1 -1
- package/src/lib/leaflet.js +1 -0
- package/src/lib/leaflet.js.map +1 -1
- package/src/lib/leaflet.mjs +1 -0
- package/src/lib/leaflet.mjs.map +1 -1
- package/src/lib/list-view.d.mts +37 -1
- package/src/lib/list-view.d.ts +37 -1
- package/src/lib/list-view.js +103 -50
- package/src/lib/list-view.js.map +1 -1
- package/src/lib/list-view.mjs +103 -51
- package/src/lib/list-view.mjs.map +1 -1
- package/src/lib/map-core.d.mts +8 -3
- package/src/lib/map-core.d.ts +8 -3
- package/src/lib/map-core.js +21 -10
- package/src/lib/map-core.js.map +1 -1
- package/src/lib/map-core.mjs +21 -10
- package/src/lib/map-core.mjs.map +1 -1
- package/src/lib/marks.d.mts +11 -0
- package/src/lib/marks.d.ts +11 -0
- package/src/lib/marks.js +26 -1
- package/src/lib/marks.js.map +1 -1
- package/src/lib/marks.mjs +23 -0
- package/src/lib/marks.mjs.map +1 -1
- package/src/lib/pins.d.mts +20 -8
- package/src/lib/pins.d.ts +20 -8
- package/src/lib/pins.js +60 -15
- package/src/lib/pins.js.map +1 -1
- package/src/lib/pins.mjs +60 -17
- package/src/lib/pins.mjs.map +1 -1
- package/src/lib/place.js +2 -1
- package/src/lib/place.js.map +1 -1
- package/src/lib/place.mjs +2 -1
- package/src/lib/place.mjs.map +1 -1
- package/src/lib/providers.d.mts +31 -5
- package/src/lib/providers.d.ts +31 -5
- package/src/lib/providers.js +80 -58
- package/src/lib/providers.js.map +1 -1
- package/src/lib/providers.mjs +80 -58
- package/src/lib/providers.mjs.map +1 -1
- package/src/lib/regions.js +18 -1
- package/src/lib/regions.js.map +1 -1
- package/src/lib/regions.mjs +18 -1
- package/src/lib/regions.mjs.map +1 -1
- package/src/lib/search-box.d.mts +7 -1
- package/src/lib/search-box.d.ts +7 -1
- package/src/lib/search-box.js +15 -10
- package/src/lib/search-box.js.map +1 -1
- package/src/lib/search-box.mjs +15 -10
- package/src/lib/search-box.mjs.map +1 -1
- package/src/lib/settings.d.mts +19 -2
- package/src/lib/settings.d.ts +19 -2
- package/src/lib/styles.d.mts +13 -2
- package/src/lib/styles.d.ts +13 -2
- package/src/lib/styles.js +69 -4
- package/src/lib/styles.js.map +1 -1
- package/src/lib/styles.mjs +67 -3
- package/src/lib/styles.mjs.map +1 -1
- package/src/lib/tools.d.mts +6 -3
- package/src/lib/tools.d.ts +6 -3
- package/src/lib/tools.js +52 -1
- package/src/lib/tools.js.map +1 -1
- package/src/lib/tools.mjs +52 -1
- package/src/lib/tools.mjs.map +1 -1
- package/src/lib/view-box.d.mts +18 -0
- package/src/lib/view-box.d.ts +18 -0
- package/src/lib/view-box.js +31 -0
- package/src/lib/view-box.js.map +1 -0
- package/src/lib/view-box.mjs +25 -0
- package/src/lib/view-box.mjs.map +1 -0
- package/src/lib/widgets.d.mts +3 -0
- package/src/lib/widgets.d.ts +3 -0
- package/src/lib/widgets.js +10 -1
- package/src/lib/widgets.js.map +1 -1
- package/src/lib/widgets.mjs +10 -1
- package/src/lib/widgets.mjs.map +1 -1
package/src/lib/card.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cardLines } from '@fieldia/core';
|
|
1
2
|
import { fill } from './labels.mjs';
|
|
2
3
|
import { imageSource, shown } from './pins.mjs';
|
|
3
4
|
function make(doc, tag, className, ...children) {
|
|
@@ -14,30 +15,83 @@ function closeButton(doc, labels, close) {
|
|
|
14
15
|
button.addEventListener('click', close);
|
|
15
16
|
return button;
|
|
16
17
|
}
|
|
18
|
+
/** A record's address on the web, when a link may go there: a web, mail or phone address, or a path of this site; never a script. */
|
|
19
|
+
export function webAddress(value) {
|
|
20
|
+
const text = typeof value === 'string' ? value.trim() : '';
|
|
21
|
+
const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(text)?.[1].toLowerCase();
|
|
22
|
+
return text && (!scheme || ['http', 'https', 'mailto', 'tel'].includes(scheme)) ? text : '';
|
|
23
|
+
}
|
|
24
|
+
const plurals = new Map();
|
|
25
|
+
/** The words after a number, in the plural form the page's language gives it: "1 bed", "4 beds". */
|
|
26
|
+
function unitWords(unit, value, locale) {
|
|
27
|
+
if (typeof unit === 'string')
|
|
28
|
+
return unit;
|
|
29
|
+
let rules = plurals.get(locale);
|
|
30
|
+
if (!rules)
|
|
31
|
+
plurals.set(locale, (rules = new Intl.PluralRules(locale)));
|
|
32
|
+
const form = typeof value === 'number' ? rules.select(value) : 'other';
|
|
33
|
+
return unit[form] ?? unit.other;
|
|
34
|
+
}
|
|
35
|
+
/** A part of a line as words: its value as the field shows it, and its own words after it, kept on one line with it. */
|
|
36
|
+
function partWords(page, part, values, locale) {
|
|
37
|
+
const said = shown(page, part.field, values, locale);
|
|
38
|
+
if (said === '' || part.unit === undefined)
|
|
39
|
+
return said;
|
|
40
|
+
const unit = unitWords(part.unit, values[part.field], locale);
|
|
41
|
+
return unit ? `${said}\u00a0${unit}` : said;
|
|
42
|
+
}
|
|
17
43
|
export function drawCard(options) {
|
|
18
|
-
const { document: doc, page, locale, labels, record } = options;
|
|
44
|
+
const { document: doc, page, locale, labels, record, card } = options;
|
|
19
45
|
const title = shown(page, options.title, record.values, locale) || String(record.id);
|
|
20
46
|
const element = make(doc, 'div', 'fd-map-card');
|
|
21
47
|
element.dir = options.dir;
|
|
22
48
|
element.setAttribute('role', 'group');
|
|
23
49
|
element.setAttribute('aria-label', title);
|
|
24
50
|
element.dataset['id'] = String(record.id);
|
|
25
|
-
const
|
|
51
|
+
const href = card.href ? webAddress(record.values[card.href]) : '';
|
|
52
|
+
/** A link to the record's own address: one a person can open in a new tab, or copy. */
|
|
53
|
+
const link = (className, ...children) => {
|
|
54
|
+
const a = make(doc, 'a', className, ...children);
|
|
55
|
+
a.href = href;
|
|
56
|
+
return a;
|
|
57
|
+
};
|
|
58
|
+
const picture = card.image ? imageSource(record.values[card.image]) : '';
|
|
26
59
|
if (picture) {
|
|
27
60
|
const img = make(doc, 'img', 'fd-map-card-image');
|
|
28
61
|
img.alt = '';
|
|
29
62
|
img.decoding = 'async';
|
|
30
63
|
img.src = picture;
|
|
31
|
-
|
|
64
|
+
// The picture goes where the title does; the title's link is the one the keys and a screen reader reach.
|
|
65
|
+
if (href) {
|
|
66
|
+
const to = link('fd-map-card-picture', img);
|
|
67
|
+
to.tabIndex = -1;
|
|
68
|
+
to.setAttribute('aria-hidden', 'true');
|
|
69
|
+
element.append(to);
|
|
70
|
+
}
|
|
71
|
+
else
|
|
72
|
+
element.append(img);
|
|
32
73
|
}
|
|
33
74
|
const body = make(doc, 'div', 'fd-map-card-body');
|
|
34
75
|
const close = closeButton(doc, labels, options.close);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
76
|
+
const name = make(doc, 'bdi', '', title);
|
|
77
|
+
body.append(make(doc, 'div', 'fd-map-card-head', make(doc, 'strong', 'fd-map-card-title', href ? link('fd-map-card-link', name) : name), close));
|
|
78
|
+
// Each line: its label (or its parts' labels), and its parts, each a value in its own direction, parted by a dot.
|
|
79
|
+
const lines = cardLines({ fields: options.fields })
|
|
80
|
+
.map((parts) => parts.map((part) => ({ part, said: partWords(page, part, record.values, locale) })).filter(({ said }) => said !== ''))
|
|
81
|
+
.filter((parts) => parts.length);
|
|
82
|
+
if (lines.length) {
|
|
83
|
+
const list = make(doc, 'dl', 'fd-map-card-fields', ...lines.map((parts) => {
|
|
84
|
+
const label = parts.map(({ part }) => page.fields[part.field]?.label ?? part.field).join(' · ');
|
|
85
|
+
const value = make(doc, 'dd', '', ...parts.flatMap(({ said }, i) => [...(i ? [' · '] : []), make(doc, 'bdi', '', said)]));
|
|
86
|
+
return make(doc, 'div', '', make(doc, 'dt', '', label), value);
|
|
87
|
+
}));
|
|
88
|
+
// Bare values, their labels said to a screen reader alone; the first line leading.
|
|
89
|
+
if (card.labels === false)
|
|
90
|
+
list.dataset['labels'] = 'hidden';
|
|
91
|
+
if (card.lead)
|
|
92
|
+
list.toggleAttribute('data-lead', true);
|
|
93
|
+
body.append(list);
|
|
94
|
+
}
|
|
41
95
|
const box = make(doc, 'input', 'fd-map-card-check');
|
|
42
96
|
box.type = 'checkbox';
|
|
43
97
|
box.checked = !!options.chosen;
|
|
@@ -52,7 +106,7 @@ export function drawCard(options) {
|
|
|
52
106
|
actions.append(button);
|
|
53
107
|
first = button;
|
|
54
108
|
}
|
|
55
|
-
if (options.open &&
|
|
109
|
+
if (options.open && card.open !== false) {
|
|
56
110
|
const open = make(doc, 'button', 'fd-button fd-button-primary fd-map-card-open', labels.openRecord);
|
|
57
111
|
open.type = 'button';
|
|
58
112
|
open.addEventListener('click', () => options.open?.());
|
|
@@ -68,7 +122,7 @@ export function drawCard(options) {
|
|
|
68
122
|
focus: () => first.focus(),
|
|
69
123
|
};
|
|
70
124
|
}
|
|
71
|
-
/** Pins on one spot that no zoom parts: a list of them, each opening its own card. */
|
|
125
|
+
/** Pins on one spot that no zoom parts: a list of them, each opening its own card; one with no card is only named. */
|
|
72
126
|
export function drawCrowd(options) {
|
|
73
127
|
const { document: doc, labels } = options;
|
|
74
128
|
const heading = fill(labels.crowd, { n: options.records.length });
|
|
@@ -77,8 +131,10 @@ export function drawCrowd(options) {
|
|
|
77
131
|
element.setAttribute('role', 'group');
|
|
78
132
|
element.setAttribute('aria-label', heading);
|
|
79
133
|
const close = closeButton(doc, labels, options.close);
|
|
80
|
-
const items = options.records.map(({ record, name }) => {
|
|
81
|
-
|
|
134
|
+
const items = options.records.map(({ record, name, plain }) => {
|
|
135
|
+
if (plain)
|
|
136
|
+
return make(doc, 'li', '', make(doc, 'span', 'fd-map-crowd-item', make(doc, 'bdi', '', name)));
|
|
137
|
+
const button = make(doc, 'button', 'fd-map-crowd-item', make(doc, 'bdi', '', name));
|
|
82
138
|
button.type = 'button';
|
|
83
139
|
button.dataset['id'] = String(record.id);
|
|
84
140
|
button.addEventListener('click', () => options.pick(record));
|
|
@@ -88,7 +144,7 @@ export function drawCrowd(options) {
|
|
|
88
144
|
return {
|
|
89
145
|
element,
|
|
90
146
|
setChosen: () => undefined,
|
|
91
|
-
focus: () => (
|
|
147
|
+
focus: () => (element.querySelector('.fd-map-crowd-list button') ?? close).focus(),
|
|
92
148
|
};
|
|
93
149
|
}
|
|
94
150
|
//# sourceMappingURL=card.mjs.map
|
package/src/lib/card.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.mjs","sourceRoot":"","sources":["../../../../../libs/map/src/lib/card.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"card.mjs","sourceRoot":"","sources":["../../../../../libs/map/src/lib/card.ts"],"names":[],"mappings":"A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,CAAC,GAAG,EAAE,KAAK,EAAE,kBAAkB,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,kBAAkB,EAAE,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,mBAAmB,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACrM,OAAO;QACL,OAAO;QACP,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS;QAC1B,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAc,2BAA2B,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,EAAE;KAChG,CAAC;AACJ,CAAC"}
|
package/src/lib/cluster.d.mts
CHANGED
|
@@ -4,9 +4,14 @@
|
|
|
4
4
|
* its points, so two bubbles' middles can fall near each other: those are
|
|
5
5
|
* gathered again, until no two lie nearer than `radius`. Points are looked
|
|
6
6
|
* up in a grid of `radius` squares, nine squares around each: thousands in a
|
|
7
|
-
* few milliseconds.
|
|
7
|
+
* few milliseconds. A point that `leads` (a place that moves, on a form's
|
|
8
|
+
* map) keeps its own spot: a group with one stands where it stands, not in
|
|
9
|
+
* the middle, and is gathered again from there; put it first, so the points
|
|
10
|
+
* round it gather to it. Returns the groups as indexes into `points`, each in
|
|
11
|
+
* order.
|
|
8
12
|
*/
|
|
9
13
|
export declare function clusterPoints(points: readonly {
|
|
10
14
|
x: number;
|
|
11
15
|
y: number;
|
|
16
|
+
leads?: boolean;
|
|
12
17
|
}[], radius: number): number[][];
|
package/src/lib/cluster.d.ts
CHANGED
|
@@ -4,9 +4,14 @@
|
|
|
4
4
|
* its points, so two bubbles' middles can fall near each other: those are
|
|
5
5
|
* gathered again, until no two lie nearer than `radius`. Points are looked
|
|
6
6
|
* up in a grid of `radius` squares, nine squares around each: thousands in a
|
|
7
|
-
* few milliseconds.
|
|
7
|
+
* few milliseconds. A point that `leads` (a place that moves, on a form's
|
|
8
|
+
* map) keeps its own spot: a group with one stands where it stands, not in
|
|
9
|
+
* the middle, and is gathered again from there; put it first, so the points
|
|
10
|
+
* round it gather to it. Returns the groups as indexes into `points`, each in
|
|
11
|
+
* order.
|
|
8
12
|
*/
|
|
9
13
|
export declare function clusterPoints(points: readonly {
|
|
10
14
|
x: number;
|
|
11
15
|
y: number;
|
|
16
|
+
leads?: boolean;
|
|
12
17
|
}[], radius: number): number[][];
|
package/src/lib/cluster.js
CHANGED
|
@@ -7,15 +7,21 @@ exports.clusterPoints = clusterPoints;
|
|
|
7
7
|
* its points, so two bubbles' middles can fall near each other: those are
|
|
8
8
|
* gathered again, until no two lie nearer than `radius`. Points are looked
|
|
9
9
|
* up in a grid of `radius` squares, nine squares around each: thousands in a
|
|
10
|
-
* few milliseconds.
|
|
10
|
+
* few milliseconds. A point that `leads` (a place that moves, on a form's
|
|
11
|
+
* map) keeps its own spot: a group with one stands where it stands, not in
|
|
12
|
+
* the middle, and is gathered again from there; put it first, so the points
|
|
13
|
+
* round it gather to it. Returns the groups as indexes into `points`, each in
|
|
14
|
+
* order.
|
|
11
15
|
*/
|
|
12
16
|
function clusterPoints(points, radius) {
|
|
13
17
|
let groups = gather(points, radius);
|
|
14
18
|
for (;;) {
|
|
15
|
-
const middles = groups.map((group) =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
const middles = groups.map((group) => {
|
|
20
|
+
const lead = group.find((i) => points[i].leads);
|
|
21
|
+
return lead === undefined
|
|
22
|
+
? { x: group.reduce((sum, i) => sum + points[i].x, 0) / group.length, y: group.reduce((sum, i) => sum + points[i].y, 0) / group.length }
|
|
23
|
+
: points[lead];
|
|
24
|
+
});
|
|
19
25
|
const merged = gather(middles, radius);
|
|
20
26
|
if (merged.length === groups.length)
|
|
21
27
|
return groups;
|
package/src/lib/cluster.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cluster.js","sourceRoot":"","sources":["../../../../../libs/map/src/lib/cluster.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"cluster.js","sourceRoot":"","sources":["../../../../../libs/map/src/lib/cluster.ts"],"names":[],"mappings":";;AAYA,sCAaC;AAzBD;;;;;;;;;;;GAWG;AACH,SAAgB,aAAa,CAAC,MAA4D,EAAE,MAAc;IACxG,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,SAAS,CAAC;QACR,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACnC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YAChD,OAAO,IAAI,KAAK,SAAS;gBACvB,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE;gBACxI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACvC,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM;YAAE,OAAO,MAAM,CAAC;QACnD,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI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AAC,CAAC;QAClB,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACrB,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACrB,KAAK,IAAI,EAAE,GAAG,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC;YAChC,KAAK,IAAI,EAAE,GAAG,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC;gBAChC,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;oBACxD,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM;wBAAE,SAAS;oBACpF,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;oBACb,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAChB,CAAC;YACH,CAAC;QACH,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/src/lib/cluster.mjs
CHANGED
|
@@ -4,15 +4,21 @@
|
|
|
4
4
|
* its points, so two bubbles' middles can fall near each other: those are
|
|
5
5
|
* gathered again, until no two lie nearer than `radius`. Points are looked
|
|
6
6
|
* up in a grid of `radius` squares, nine squares around each: thousands in a
|
|
7
|
-
* few milliseconds.
|
|
7
|
+
* few milliseconds. A point that `leads` (a place that moves, on a form's
|
|
8
|
+
* map) keeps its own spot: a group with one stands where it stands, not in
|
|
9
|
+
* the middle, and is gathered again from there; put it first, so the points
|
|
10
|
+
* round it gather to it. Returns the groups as indexes into `points`, each in
|
|
11
|
+
* order.
|
|
8
12
|
*/
|
|
9
13
|
export function clusterPoints(points, radius) {
|
|
10
14
|
let groups = gather(points, radius);
|
|
11
15
|
for (;;) {
|
|
12
|
-
const middles = groups.map((group) =>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
const middles = groups.map((group) => {
|
|
17
|
+
const lead = group.find((i) => points[i].leads);
|
|
18
|
+
return lead === undefined
|
|
19
|
+
? { x: group.reduce((sum, i) => sum + points[i].x, 0) / group.length, y: group.reduce((sum, i) => sum + points[i].y, 0) / group.length }
|
|
20
|
+
: points[lead];
|
|
21
|
+
});
|
|
16
22
|
const merged = gather(middles, radius);
|
|
17
23
|
if (merged.length === groups.length)
|
|
18
24
|
return groups;
|
package/src/lib/cluster.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cluster.mjs","sourceRoot":"","sources":["../../../../../libs/map/src/lib/cluster.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cluster.mjs","sourceRoot":"","sources":["../../../../../libs/map/src/lib/cluster.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAAC,MAA4D,EAAE,MAAc;IACxG,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,SAAS,CAAC;QACR,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACnC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YAChD,OAAO,IAA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AAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM;wBAAE,SAAS;oBACpF,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;oBACb,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAChB,CAAC;YACH,CAAC;QACH,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { type DataSource, type Page, type RecordId, type ResolvedFilter, type SortOrder } from '@fieldia/core';
|
|
2
|
+
import type { ListViewPart } from '@fieldia/viewer';
|
|
3
|
+
import type { IconSet } from '@fieldia/widgets';
|
|
4
|
+
import type { LatLng } from './geo.mjs';
|
|
5
|
+
import { type MapSearch, type MapViewChange } from './list-view.mjs';
|
|
6
|
+
import type { MapRecord } from './pins.mjs';
|
|
7
|
+
import type { MapSettings } from './settings.mjs';
|
|
8
|
+
/**
|
|
9
|
+
* A list's map in a page of the app's own, outside the viewer: the page's
|
|
10
|
+
* own list, filters and address beside it, the map drawn by Fieldia. The
|
|
11
|
+
* app gives the page that describes the records (a list with `map`), where
|
|
12
|
+
* the records come from, the search they were found by, and what to do when
|
|
13
|
+
* the map asks for something; it gets the map back, to reload and destroy.
|
|
14
|
+
* The map brings its own base (its buttons, a part hidden, words for a
|
|
15
|
+
* screen reader) on its own element, and Fieldia's colours as tokens the
|
|
16
|
+
* page can set: none of it reaches the page round it.
|
|
17
|
+
*
|
|
18
|
+
* const map = mountListMap(element, {
|
|
19
|
+
* page, // a list page with "map"
|
|
20
|
+
* provider: azureMaps({ key }),
|
|
21
|
+
* dataSource, // or records: [...]
|
|
22
|
+
* filter: () => searchNow(), // the conditions the records are found by
|
|
23
|
+
* start: { center: { lat: 30.05, lng: 31.23 }, zoom: 12 }, // from the address, say
|
|
24
|
+
* onSearch: ({ kind, filter }) => { keep(kind, filter); map.reload(); },
|
|
25
|
+
* onViewChange: ({ center, zoom }) => history.replaceState(null, '', `?at=${center.lat},${center.lng},${zoom}`),
|
|
26
|
+
* onOpenRecord: (id) => location.assign(`/homes/${id}`),
|
|
27
|
+
* onHighlight: (id) => lightRow(id),
|
|
28
|
+
* });
|
|
29
|
+
*/
|
|
30
|
+
export interface ListMapOptions extends MapSettings {
|
|
31
|
+
/** The page that describes the records: their fields, and a list with `map` (where each is, its pin, its card, its height, its gestures). */
|
|
32
|
+
page: Page;
|
|
33
|
+
/** Where the records come from: a source with `list`, asked with the search, the list's order and the map's `limit`. */
|
|
34
|
+
dataSource?: DataSource;
|
|
35
|
+
/** Or the records themselves, found already: each `{ id, values }`, or a function giving them, asked again at each `reload()`. */
|
|
36
|
+
records?: readonly MapRecord[] | (() => readonly MapRecord[] | Promise<readonly MapRecord[]>);
|
|
37
|
+
/** The language: a tag such as `ar-EG`; Fieldia's words in English, Arabic, French or German, and the page's own `translations`. The document's language unless said. */
|
|
38
|
+
locale?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The conditions the records are found by now, as a search bar's are: the
|
|
41
|
+
* map asks its source with them, draws the areas among them, and counts
|
|
42
|
+
* a view within them. A search the map asked for is among them once the app
|
|
43
|
+
* has taken it.
|
|
44
|
+
*/
|
|
45
|
+
filter?: readonly ResolvedFilter[] | (() => readonly ResolvedFilter[]);
|
|
46
|
+
/** The order the records come in: the map shows the same first ones as the page's own list. */
|
|
47
|
+
sort?: readonly SortOrder[] | (() => readonly SortOrder[]);
|
|
48
|
+
/** Where the map opens, from the page's address, say: there it fits no records at first, until the search changes. */
|
|
49
|
+
start?: {
|
|
50
|
+
center: LatLng;
|
|
51
|
+
zoom: number;
|
|
52
|
+
};
|
|
53
|
+
/** The app's icons for the pins, besides Fieldia's and the map's own. */
|
|
54
|
+
icons?: IconSet;
|
|
55
|
+
/** The page's buttons for one record, offered on its card: "Book a viewing". */
|
|
56
|
+
actions?: {
|
|
57
|
+
id: string;
|
|
58
|
+
label: string;
|
|
59
|
+
style?: 'primary' | 'secondary' | 'danger' | 'link';
|
|
60
|
+
}[];
|
|
61
|
+
/** A card's Open: the card has the button when this is given. */
|
|
62
|
+
onOpenRecord?: (id: RecordId) => void;
|
|
63
|
+
/** A pin under the pointer or the focus (null when none): light the record in the page's own list. */
|
|
64
|
+
onHighlight?: (id: RecordId | null) => void;
|
|
65
|
+
/**
|
|
66
|
+
* The map asks for a search: its view (`kind: 'view'`, "Search this area"),
|
|
67
|
+
* an area drawn (`drawn`), or a shaded area pressed (`region`). The app
|
|
68
|
+
* keeps one of each kind, a new one in the last one's place, as a search bar
|
|
69
|
+
* does, puts its conditions in `filter`, and calls `reload()`. Without it the
|
|
70
|
+
* map offers no search: no "Search this area", no tools to draw an area.
|
|
71
|
+
*/
|
|
72
|
+
onSearch?: (search: MapSearch) => void;
|
|
73
|
+
/** The map has stopped, after a move or a zoom: where it stands, to keep in the page's address. Each view once. */
|
|
74
|
+
onViewChange?: (view: MapViewChange) => void;
|
|
75
|
+
/** Whether a record is chosen, and a choice made on its card; the map keeps its own choice when these are not given. */
|
|
76
|
+
isChosen?: (id: RecordId) => boolean;
|
|
77
|
+
onChoose?: (id: RecordId, chosen: boolean) => void;
|
|
78
|
+
/** One of `actions` pressed on a record's card: the button is busy until it is done. */
|
|
79
|
+
onAction?: (id: string, ids: RecordId[]) => void | Promise<void>;
|
|
80
|
+
/** "Nearest first" pressed: the order the page's own list should take too (null: its own again). */
|
|
81
|
+
onSort?: (order: SortOrder[] | null) => void;
|
|
82
|
+
}
|
|
83
|
+
/** A list's map in a page: its element (already in the page), and what the page asks of it. */
|
|
84
|
+
export type ListMapHandle = ListViewPart;
|
|
85
|
+
/** Puts a list's map into `host`, loads its records, and hands it back. Throws when the page cannot be shown, saying why. */
|
|
86
|
+
export declare function mountListMap(host: HTMLElement, options: ListMapOptions): ListMapHandle;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { type DataSource, type Page, type RecordId, type ResolvedFilter, type SortOrder } from '@fieldia/core';
|
|
2
|
+
import type { ListViewPart } from '@fieldia/viewer';
|
|
3
|
+
import type { IconSet } from '@fieldia/widgets';
|
|
4
|
+
import type { LatLng } from './geo';
|
|
5
|
+
import { type MapSearch, type MapViewChange } from './list-view';
|
|
6
|
+
import type { MapRecord } from './pins';
|
|
7
|
+
import type { MapSettings } from './settings';
|
|
8
|
+
/**
|
|
9
|
+
* A list's map in a page of the app's own, outside the viewer: the page's
|
|
10
|
+
* own list, filters and address beside it, the map drawn by Fieldia. The
|
|
11
|
+
* app gives the page that describes the records (a list with `map`), where
|
|
12
|
+
* the records come from, the search they were found by, and what to do when
|
|
13
|
+
* the map asks for something; it gets the map back, to reload and destroy.
|
|
14
|
+
* The map brings its own base (its buttons, a part hidden, words for a
|
|
15
|
+
* screen reader) on its own element, and Fieldia's colours as tokens the
|
|
16
|
+
* page can set: none of it reaches the page round it.
|
|
17
|
+
*
|
|
18
|
+
* const map = mountListMap(element, {
|
|
19
|
+
* page, // a list page with "map"
|
|
20
|
+
* provider: azureMaps({ key }),
|
|
21
|
+
* dataSource, // or records: [...]
|
|
22
|
+
* filter: () => searchNow(), // the conditions the records are found by
|
|
23
|
+
* start: { center: { lat: 30.05, lng: 31.23 }, zoom: 12 }, // from the address, say
|
|
24
|
+
* onSearch: ({ kind, filter }) => { keep(kind, filter); map.reload(); },
|
|
25
|
+
* onViewChange: ({ center, zoom }) => history.replaceState(null, '', `?at=${center.lat},${center.lng},${zoom}`),
|
|
26
|
+
* onOpenRecord: (id) => location.assign(`/homes/${id}`),
|
|
27
|
+
* onHighlight: (id) => lightRow(id),
|
|
28
|
+
* });
|
|
29
|
+
*/
|
|
30
|
+
export interface ListMapOptions extends MapSettings {
|
|
31
|
+
/** The page that describes the records: their fields, and a list with `map` (where each is, its pin, its card, its height, its gestures). */
|
|
32
|
+
page: Page;
|
|
33
|
+
/** Where the records come from: a source with `list`, asked with the search, the list's order and the map's `limit`. */
|
|
34
|
+
dataSource?: DataSource;
|
|
35
|
+
/** Or the records themselves, found already: each `{ id, values }`, or a function giving them, asked again at each `reload()`. */
|
|
36
|
+
records?: readonly MapRecord[] | (() => readonly MapRecord[] | Promise<readonly MapRecord[]>);
|
|
37
|
+
/** The language: a tag such as `ar-EG`; Fieldia's words in English, Arabic, French or German, and the page's own `translations`. The document's language unless said. */
|
|
38
|
+
locale?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The conditions the records are found by now, as a search bar's are: the
|
|
41
|
+
* map asks its source with them, draws the areas among them, and counts
|
|
42
|
+
* a view within them. A search the map asked for is among them once the app
|
|
43
|
+
* has taken it.
|
|
44
|
+
*/
|
|
45
|
+
filter?: readonly ResolvedFilter[] | (() => readonly ResolvedFilter[]);
|
|
46
|
+
/** The order the records come in: the map shows the same first ones as the page's own list. */
|
|
47
|
+
sort?: readonly SortOrder[] | (() => readonly SortOrder[]);
|
|
48
|
+
/** Where the map opens, from the page's address, say: there it fits no records at first, until the search changes. */
|
|
49
|
+
start?: {
|
|
50
|
+
center: LatLng;
|
|
51
|
+
zoom: number;
|
|
52
|
+
};
|
|
53
|
+
/** The app's icons for the pins, besides Fieldia's and the map's own. */
|
|
54
|
+
icons?: IconSet;
|
|
55
|
+
/** The page's buttons for one record, offered on its card: "Book a viewing". */
|
|
56
|
+
actions?: {
|
|
57
|
+
id: string;
|
|
58
|
+
label: string;
|
|
59
|
+
style?: 'primary' | 'secondary' | 'danger' | 'link';
|
|
60
|
+
}[];
|
|
61
|
+
/** A card's Open: the card has the button when this is given. */
|
|
62
|
+
onOpenRecord?: (id: RecordId) => void;
|
|
63
|
+
/** A pin under the pointer or the focus (null when none): light the record in the page's own list. */
|
|
64
|
+
onHighlight?: (id: RecordId | null) => void;
|
|
65
|
+
/**
|
|
66
|
+
* The map asks for a search: its view (`kind: 'view'`, "Search this area"),
|
|
67
|
+
* an area drawn (`drawn`), or a shaded area pressed (`region`). The app
|
|
68
|
+
* keeps one of each kind, a new one in the last one's place, as a search bar
|
|
69
|
+
* does, puts its conditions in `filter`, and calls `reload()`. Without it the
|
|
70
|
+
* map offers no search: no "Search this area", no tools to draw an area.
|
|
71
|
+
*/
|
|
72
|
+
onSearch?: (search: MapSearch) => void;
|
|
73
|
+
/** The map has stopped, after a move or a zoom: where it stands, to keep in the page's address. Each view once. */
|
|
74
|
+
onViewChange?: (view: MapViewChange) => void;
|
|
75
|
+
/** Whether a record is chosen, and a choice made on its card; the map keeps its own choice when these are not given. */
|
|
76
|
+
isChosen?: (id: RecordId) => boolean;
|
|
77
|
+
onChoose?: (id: RecordId, chosen: boolean) => void;
|
|
78
|
+
/** One of `actions` pressed on a record's card: the button is busy until it is done. */
|
|
79
|
+
onAction?: (id: string, ids: RecordId[]) => void | Promise<void>;
|
|
80
|
+
/** "Nearest first" pressed: the order the page's own list should take too (null: its own again). */
|
|
81
|
+
onSort?: (order: SortOrder[] | null) => void;
|
|
82
|
+
}
|
|
83
|
+
/** A list's map in a page: its element (already in the page), and what the page asks of it. */
|
|
84
|
+
export type ListMapHandle = ListViewPart;
|
|
85
|
+
/** Puts a list's map into `host`, loads its records, and hands it back. Throws when the page cannot be shown, saying why. */
|
|
86
|
+
export declare function mountListMap(host: HTMLElement, options: ListMapOptions): ListMapHandle;
|
package/src/lib/embed.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mountListMap = mountListMap;
|
|
4
|
+
const core_1 = require("@fieldia/core");
|
|
5
|
+
const list_view_1 = require("./list-view");
|
|
6
|
+
const styles_1 = require("./styles");
|
|
7
|
+
const OWN = ['en', 'ar', 'fr', 'de'];
|
|
8
|
+
/** Puts a list's map into `host`, loads its records, and hands it back. Throws when the page cannot be shown, saying why. */
|
|
9
|
+
function mountListMap(host, options) {
|
|
10
|
+
const doc = host.ownerDocument;
|
|
11
|
+
const checked = (0, core_1.checkPage)(options.page);
|
|
12
|
+
if (!checked.ok)
|
|
13
|
+
throw new Error(`This page cannot be shown:\n${checked.issues.map((i) => ` ${i.path}: ${i.message}`).join('\n')}`);
|
|
14
|
+
const tag = options.locale ?? (doc.documentElement.lang || checked.page.language || 'en');
|
|
15
|
+
const page = (0, core_1.localizePage)(checked.page, tag);
|
|
16
|
+
const node = page.layout;
|
|
17
|
+
if (node.type !== 'list' || !node.map)
|
|
18
|
+
throw new Error('mountListMap shows a list page with "map": its layout is a list, and its map says where each record is.');
|
|
19
|
+
const base = tag.split('-')[0].toLowerCase();
|
|
20
|
+
const locale = OWN.includes(base) ? base : 'en';
|
|
21
|
+
const read = (given, none) => (typeof given === 'function' ? given() : (given ?? none));
|
|
22
|
+
// The records given, as a source that hands them over as they are: the search found them already.
|
|
23
|
+
const given = options.records;
|
|
24
|
+
const dataSource = given
|
|
25
|
+
? {
|
|
26
|
+
async list() {
|
|
27
|
+
const records = [...(await read(given, []))];
|
|
28
|
+
return { records, total: records.length };
|
|
29
|
+
},
|
|
30
|
+
}
|
|
31
|
+
: options.dataSource;
|
|
32
|
+
const chosen = new Set();
|
|
33
|
+
let order = null;
|
|
34
|
+
let part = null;
|
|
35
|
+
(0, styles_1.installEmbedStyles)(doc);
|
|
36
|
+
part = (0, list_view_1.listMap)(options, {
|
|
37
|
+
page,
|
|
38
|
+
node,
|
|
39
|
+
dataSource,
|
|
40
|
+
document: doc,
|
|
41
|
+
locale,
|
|
42
|
+
...(options.icons ? { icons: options.icons } : {}),
|
|
43
|
+
...(options.start ? { start: options.start } : {}),
|
|
44
|
+
given: !!given,
|
|
45
|
+
searches: !!options.onSearch,
|
|
46
|
+
filter: () => [...read(options.filter, [])],
|
|
47
|
+
sort: () => order ?? [...read(options.sort, [])],
|
|
48
|
+
sortBy(next) {
|
|
49
|
+
order = next;
|
|
50
|
+
options.onSort?.(next);
|
|
51
|
+
void part?.reload();
|
|
52
|
+
},
|
|
53
|
+
isChosen: (id) => (options.isChosen ? options.isChosen(id) : chosen.has(id)),
|
|
54
|
+
choose(id, on) {
|
|
55
|
+
if (on)
|
|
56
|
+
chosen.add(id);
|
|
57
|
+
else
|
|
58
|
+
chosen.delete(id);
|
|
59
|
+
options.onChoose?.(id, on);
|
|
60
|
+
part?.chosenChanged();
|
|
61
|
+
},
|
|
62
|
+
...(options.onOpenRecord ? { open: options.onOpenRecord } : {}),
|
|
63
|
+
highlight: (id) => options.onHighlight?.(id),
|
|
64
|
+
addSearch: (search) => options.onSearch?.(search),
|
|
65
|
+
actions: options.actions ?? [],
|
|
66
|
+
async act(id, ids, button) {
|
|
67
|
+
button.setAttribute('aria-busy', 'true');
|
|
68
|
+
try {
|
|
69
|
+
await options.onAction?.(id, ids);
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
button.removeAttribute('aria-busy');
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
const element = part.element;
|
|
77
|
+
element.classList.add('fd-map-embed');
|
|
78
|
+
const viewChanged = (event) => options.onViewChange?.(event.detail);
|
|
79
|
+
element.addEventListener('fd-map-view', viewChanged);
|
|
80
|
+
host.append(element);
|
|
81
|
+
void part.reload();
|
|
82
|
+
const shown = part;
|
|
83
|
+
return {
|
|
84
|
+
element,
|
|
85
|
+
reload: () => shown.reload(),
|
|
86
|
+
highlight: (id) => shown.highlight(id),
|
|
87
|
+
chosenChanged: () => shown.chosenChanged(),
|
|
88
|
+
shown: () => shown.shown(),
|
|
89
|
+
destroy() {
|
|
90
|
+
element.removeEventListener('fd-map-view', viewChanged);
|
|
91
|
+
shown.destroy();
|
|
92
|
+
element.remove();
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=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