@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/README.md
CHANGED
|
@@ -108,6 +108,59 @@ styles or its words.
|
|
|
108
108
|
A card offers the list's own buttons too, each pressed for its record alone
|
|
109
109
|
("Assign", for this driver).
|
|
110
110
|
|
|
111
|
+
How the map sits in its page: `height` is pixels, or `fill` (as tall as the
|
|
112
|
+
element it is put in), as tall as the window allows (320 to 640 pixels) unless
|
|
113
|
+
said; `gestures: "all"` lets the map take every gesture — one finger pans, the
|
|
114
|
+
wheel zooms with no key held — where it is most of its page (unless said, one
|
|
115
|
+
finger and the wheel scroll the page past it); `fitZoom` is the closest it comes
|
|
116
|
+
when it fits its records, 16 unless said.
|
|
117
|
+
|
|
118
|
+
Once the map is moved, "Search this area" says how many records the view holds,
|
|
119
|
+
"Search this area (24)", when the records on hand can tell (all the search
|
|
120
|
+
finds, and a view within any area already searched). Otherwise, with
|
|
121
|
+
`countArea: true` in the settings, the data source is asked: one record, its
|
|
122
|
+
`total` the count, a moment after the map stops, the request's `signal` aborted
|
|
123
|
+
when it moves again; or `countArea` is the app's own
|
|
124
|
+
`(filter, signal) => Promise<number>`. Each time it stops, the map's element
|
|
125
|
+
sends `fd-map-view` (it bubbles): `{ center, zoom, bounds, byPerson }`.
|
|
126
|
+
|
|
127
|
+
## A list's map in a page of your own
|
|
128
|
+
|
|
129
|
+
A page that is not Fieldia's — its own list, filters and address — shows a list's
|
|
130
|
+
map beside them with `mountListMap`. The app gives the page that describes the
|
|
131
|
+
records (a list with `map`), a data source or the records themselves, the
|
|
132
|
+
conditions they are found by, and what to do when the map asks for something; it
|
|
133
|
+
gets back the map.
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
import { mountListMap, azureMaps } from '@fieldia/map';
|
|
137
|
+
|
|
138
|
+
const map = mountListMap(element, {
|
|
139
|
+
page, // a list page with "map"
|
|
140
|
+
provider: azureMaps({ key }),
|
|
141
|
+
dataSource, // or records: [{ id, values }, …]
|
|
142
|
+
filter: () => yourSearch(), // the conditions the records are found by
|
|
143
|
+
start: { center: { lat: 30.05, lng: 31.23 }, zoom: 13 }, // from the address: no fit at first
|
|
144
|
+
countArea: true,
|
|
145
|
+
onSearch: ({ kind, filter }) => { keep(kind, filter); map.reload(); }, // 'view', 'drawn' or 'region'
|
|
146
|
+
onViewChange: ({ center, zoom, bounds, byPerson }) => writeTheAddress(center, zoom),
|
|
147
|
+
onHighlight: (id) => lightYourRow(id),
|
|
148
|
+
onOpenRecord: (id) => location.assign(`/homes/${id}`),
|
|
149
|
+
});
|
|
150
|
+
map.highlight(id); // a row of yours under the pointer
|
|
151
|
+
map.reload(); // your search changed
|
|
152
|
+
map.destroy();
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Also `locale` (a tag; the document's language unless said), `sort`, `icons`,
|
|
156
|
+
`isChosen` and `onChoose`, `actions` and `onAction`, `onSort` (Nearest first),
|
|
157
|
+
and every setting `mapListViews` takes. Without `onSearch` the map offers no
|
|
158
|
+
search. It brings its own base on its own element alone (a part hidden stays
|
|
159
|
+
hidden, words for a screen reader, its buttons) and Fieldia's colours as tokens,
|
|
160
|
+
light or dark by the page's `color-scheme`: set your own on `.fd-map-embed`
|
|
161
|
+
(`.fd-map-embed { --fd-accent: #375dfb; }`), and your rule wins whatever its
|
|
162
|
+
weight.
|
|
163
|
+
|
|
111
164
|
## A map on a form
|
|
112
165
|
|
|
113
166
|
A part of type `map` shows the record's places as layers: the record's own
|
|
@@ -136,6 +189,14 @@ seconds, metres and line go into. Routes come from the provider (`route`),
|
|
|
136
189
|
loaded the first time one is asked for, or from the app's own `route` in the
|
|
137
190
|
settings.
|
|
138
191
|
|
|
192
|
+
Pins that crowd are gathered as a list's map gathers them, again at each zoom:
|
|
193
|
+
a bubble with their count ("2 here: Delta Foods, Amira Clinics. Zoom in to see
|
|
194
|
+
them."), pressed to zoom in until they part, or to list them when they stand on
|
|
195
|
+
one spot. A place that moves is never hidden in a bubble: the pins that crowd
|
|
196
|
+
it are gathered under it, and it wears their count, still gliding, greying and
|
|
197
|
+
followed. Routes, reachable areas and fences read where places are, never where
|
|
198
|
+
a bubble stands.
|
|
199
|
+
|
|
139
200
|
## Areas by colour, reach and fences
|
|
140
201
|
|
|
141
202
|
Districts, zones or municipalities shaded in up to five steps of the page's
|
|
@@ -163,8 +224,10 @@ the browser showing the map: what must happen once, your server watches.
|
|
|
163
224
|
|
|
164
225
|
A list's map with `heat` shows its records as a heat map from afar (each
|
|
165
226
|
weighing one, or `weight`), their pins back at the streets. Any map takes
|
|
166
|
-
`tools`: `satellite`, `
|
|
167
|
-
|
|
227
|
+
`tools`: `satellite`, `traffic` (the provider's live traffic over the map),
|
|
228
|
+
`fullscreen`, `measure`, and on a list's map `nearest` (its records nearest the
|
|
229
|
+
reader first, the data source sorting by `near`). A provider with no satellite
|
|
230
|
+
images or no traffic shows no button for them.
|
|
168
231
|
Areas, reach, fences, the heat map and the tools each load with the first map
|
|
169
232
|
that has them.
|
|
170
233
|
|
|
@@ -180,17 +243,19 @@ move the map.
|
|
|
180
243
|
|
|
181
244
|
On a list's map, Tab goes from the map to each pin and bubble by its name;
|
|
182
245
|
Enter or Space opens a pin's card (Ctrl or ⌘ with it chooses the record) or
|
|
183
|
-
zooms into a bubble, and Escape closes the card, back on its pin.
|
|
246
|
+
zooms into a bubble, and Escape closes the card, back on its pin. A form's map
|
|
247
|
+
does the same, its bubbles saying whose pins they hold; the keys stay on the
|
|
248
|
+
pin, or the bubble, that holds the place they were on.
|
|
184
249
|
|
|
185
250
|
## Providers
|
|
186
251
|
|
|
187
|
-
| Provider | Road | Dark | Satellite | Address search | Routes | Reachable area |
|
|
188
|
-
| --- | --- | --- | --- | --- | --- | --- |
|
|
189
|
-
| `azureMaps({ key })` or `({ token, clientId })` | yes | yes | yes | yes, as people type | car, foot | car |
|
|
190
|
-
| `googleMaps({ key, region, logo })` (Map Tiles API) | yes | no | yes | Places API, as people type | car, bike, foot (Routes API) | no |
|
|
191
|
-
| `mapbox({ token })` | yes | yes | yes | yes, as people type | car (traffic), bike, foot | car, bike, foot |
|
|
192
|
-
| `tiles({ url, credit, route, reach })` | the app's own map images | | | the app's own | the app's own | the app's own |
|
|
193
|
-
| `openStreetMap()` | yes, **for demos only** | no | no | Photon, as people type, nearest first (or `{ search: 'nominatim' }`, on Enter) | OSRM's demo server, car only (or `osrmUrl`) | no |
|
|
252
|
+
| Provider | Road | Dark | Satellite | Traffic | Address search | Routes | Reachable area |
|
|
253
|
+
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
254
|
+
| `azureMaps({ key })` or `({ token, clientId })` | yes | yes | yes | yes, from zoom 6, in dark colours on the dark map, drawn again every four minutes | yes, as people type | car, foot | car |
|
|
255
|
+
| `googleMaps({ key, region, logo })` (Map Tiles API) | yes | no | yes | yes, its traffic layer | Places API, as people type | car, bike, foot (Routes API) | no |
|
|
256
|
+
| `mapbox({ token, trafficStyle })` | yes | yes | yes | from `trafficStyle`, a style of yours with Mapbox Traffic's lines alone | yes, as people type | car (traffic), bike, foot | car, bike, foot |
|
|
257
|
+
| `tiles({ url, credit, trafficUrl, route, reach })` | the app's own map images | | | the app's own (`trafficUrl`) | the app's own | the app's own | the app's own |
|
|
258
|
+
| `openStreetMap()` | yes, **for demos only** | no | no | no | Photon, as people type, nearest first (or `{ search: 'nominatim' }`, on Enter) | OSRM's demo server, car only (or `osrmUrl`) | no |
|
|
194
259
|
|
|
195
260
|
Keys never live in Fieldia: pass one restricted to your sites, or a function
|
|
196
261
|
fetching a short-lived token from your server. Each provider's credits are shown
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fieldia/map",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Fieldia's maps: a place and an area as fields, and a list's records on a map, on any map provider. Leaflet, loaded only where a map is shown.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://fieldia.dev",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"./package.json": "./package.json"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@fieldia/core": "0.
|
|
25
|
-
"@fieldia/viewer": "0.
|
|
26
|
-
"@fieldia/widgets": "0.
|
|
24
|
+
"@fieldia/core": "0.19.0",
|
|
25
|
+
"@fieldia/viewer": "0.19.0",
|
|
26
|
+
"@fieldia/widgets": "0.19.0",
|
|
27
27
|
"leaflet": "^1.9.4",
|
|
28
28
|
"tslib": "^2.8.1"
|
|
29
29
|
},
|
package/src/index.d.mts
CHANGED
|
@@ -8,3 +8,8 @@ export type { MapSettings } from './lib/settings.mjs';
|
|
|
8
8
|
export { azureMaps, googleMaps, mapbox, openStreetMap, tiles, type AddressSearch, type AzureMapsOptions, type BaseMap, type Credit, type GoogleMapsOptions, type MapboxOptions, type MapProvider, type MapView, type OpenStreetMapOptions, type PlaceFound, type ReachFinder, type ReachFound, type ReachRequest, type ReverseSearch, type RouteFinder, type RouteFound, type RouteRequest, type TravelMode, type SearchRequest, type TileSpec, type TilesOptions, } from './lib/providers.mjs';
|
|
9
9
|
export { readArea, readPoint, writeArea, writePoint, metresBetween, type Area, type AreaFeature, type LatLng, type PointGeometry, type Shape } from './lib/geo.mjs';
|
|
10
10
|
export { MAP_LABELS, type MapLabels } from './lib/labels.mjs';
|
|
11
|
+
export type { AddressLabels } from './lib/address-labels.mjs';
|
|
12
|
+
export type { AddressParts } from './lib/address-parts.mjs';
|
|
13
|
+
export { mountListMap, type ListMapHandle, type ListMapOptions } from './lib/embed.mjs';
|
|
14
|
+
export type { MapSearch, MapViewChange } from './lib/list-view.mjs';
|
|
15
|
+
export type { Box as MapBounds } from './lib/view-box.mjs';
|
package/src/index.d.ts
CHANGED
|
@@ -8,3 +8,8 @@ export type { MapSettings } from './lib/settings';
|
|
|
8
8
|
export { azureMaps, googleMaps, mapbox, openStreetMap, tiles, type AddressSearch, type AzureMapsOptions, type BaseMap, type Credit, type GoogleMapsOptions, type MapboxOptions, type MapProvider, type MapView, type OpenStreetMapOptions, type PlaceFound, type ReachFinder, type ReachFound, type ReachRequest, type ReverseSearch, type RouteFinder, type RouteFound, type RouteRequest, type TravelMode, type SearchRequest, type TileSpec, type TilesOptions, } from './lib/providers';
|
|
9
9
|
export { readArea, readPoint, writeArea, writePoint, metresBetween, type Area, type AreaFeature, type LatLng, type PointGeometry, type Shape } from './lib/geo';
|
|
10
10
|
export { MAP_LABELS, type MapLabels } from './lib/labels';
|
|
11
|
+
export type { AddressLabels } from './lib/address-labels';
|
|
12
|
+
export type { AddressParts } from './lib/address-parts';
|
|
13
|
+
export { mountListMap, type ListMapHandle, type ListMapOptions } from './lib/embed';
|
|
14
|
+
export type { MapSearch, MapViewChange } from './lib/list-view';
|
|
15
|
+
export type { Box as MapBounds } from './lib/view-box';
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MAP_LABELS = exports.metresBetween = exports.writePoint = exports.writeArea = exports.readPoint = exports.readArea = exports.tiles = exports.openStreetMap = exports.mapbox = exports.googleMaps = exports.azureMaps = exports.mapKinds = exports.MAP_ICONS = exports.mapParts = exports.mapListViews = exports.mapWidgets = void 0;
|
|
3
|
+
exports.mountListMap = exports.MAP_LABELS = exports.metresBetween = exports.writePoint = exports.writeArea = exports.readPoint = exports.readArea = exports.tiles = exports.openStreetMap = exports.mapbox = exports.googleMaps = exports.azureMaps = exports.mapKinds = exports.MAP_ICONS = exports.mapParts = exports.mapListViews = exports.mapWidgets = void 0;
|
|
4
4
|
var widgets_1 = require("./lib/widgets");
|
|
5
5
|
Object.defineProperty(exports, "mapWidgets", { enumerable: true, get: function () { return widgets_1.mapWidgets; } });
|
|
6
6
|
var list_view_1 = require("./lib/list-view");
|
|
@@ -25,4 +25,7 @@ Object.defineProperty(exports, "writePoint", { enumerable: true, get: function (
|
|
|
25
25
|
Object.defineProperty(exports, "metresBetween", { enumerable: true, get: function () { return geo_1.metresBetween; } });
|
|
26
26
|
var labels_1 = require("./lib/labels");
|
|
27
27
|
Object.defineProperty(exports, "MAP_LABELS", { enumerable: true, get: function () { return labels_1.MAP_LABELS; } });
|
|
28
|
+
// A list's map in a page of the app's own, outside the viewer.
|
|
29
|
+
var embed_1 = require("./lib/embed");
|
|
30
|
+
Object.defineProperty(exports, "mountListMap", { enumerable: true, get: function () { return embed_1.mountListMap; } });
|
|
28
31
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/map/src/index.ts"],"names":[],"mappings":";;;AAAA,yCAA2C;AAAlC,qGAAA,UAAU,OAAA;AACnB,6CAA+C;AAAtC,yGAAA,YAAY,OAAA;AACrB,2CAA0C;AAAjC,oGAAA,QAAQ,OAAA;AACjB,6CAA4C;AAAnC,sGAAA,SAAS,OAAA;AAElB,qCAA0E;AAAjE,iGAAA,QAAQ,OAAA;AAEjB,6CA2ByB;AA1BvB,sGAAA,SAAS,OAAA;AACT,uGAAA,UAAU,OAAA;AACV,mGAAA,MAAM,OAAA;AACN,0GAAA,aAAa,OAAA;AACb,kGAAA,KAAK,OAAA;AAuBP,iCAAgK;AAAvJ,+FAAA,QAAQ,OAAA;AAAE,gGAAA,SAAS,OAAA;AAAE,gGAAA,SAAS,OAAA;AAAE,iGAAA,UAAU,OAAA;AAAE,oGAAA,aAAa,OAAA;AAClE,uCAA0D;AAAjD,oGAAA,UAAU,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/map/src/index.ts"],"names":[],"mappings":";;;AAAA,yCAA2C;AAAlC,qGAAA,UAAU,OAAA;AACnB,6CAA+C;AAAtC,yGAAA,YAAY,OAAA;AACrB,2CAA0C;AAAjC,oGAAA,QAAQ,OAAA;AACjB,6CAA4C;AAAnC,sGAAA,SAAS,OAAA;AAElB,qCAA0E;AAAjE,iGAAA,QAAQ,OAAA;AAEjB,6CA2ByB;AA1BvB,sGAAA,SAAS,OAAA;AACT,uGAAA,UAAU,OAAA;AACV,mGAAA,MAAM,OAAA;AACN,0GAAA,aAAa,OAAA;AACb,kGAAA,KAAK,OAAA;AAuBP,iCAAgK;AAAvJ,+FAAA,QAAQ,OAAA;AAAE,gGAAA,SAAS,OAAA;AAAE,gGAAA,SAAS,OAAA;AAAE,iGAAA,UAAU,OAAA;AAAE,oGAAA,aAAa,OAAA;AAClE,uCAA0D;AAAjD,oGAAA,UAAU,OAAA;AAGnB,+DAA+D;AAC/D,qCAAoF;AAA3E,qGAAA,YAAY,OAAA"}
|
package/src/index.mjs
CHANGED
|
@@ -6,4 +6,6 @@ export { mapKinds } from './lib/kinds.mjs';
|
|
|
6
6
|
export { azureMaps, googleMaps, mapbox, openStreetMap, tiles, } from './lib/providers.mjs';
|
|
7
7
|
export { readArea, readPoint, writeArea, writePoint, metresBetween } from './lib/geo.mjs';
|
|
8
8
|
export { MAP_LABELS } from './lib/labels.mjs';
|
|
9
|
+
// A list's map in a page of the app's own, outside the viewer.
|
|
10
|
+
export { mountListMap } from './lib/embed.mjs';
|
|
9
11
|
//# sourceMappingURL=index.mjs.map
|
package/src/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../libs/map/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAqC,MAAM,aAAa,CAAC;AAE1E,OAAO,EACL,SAAS,EACT,UAAU,EACV,MAAM,EACN,aAAa,EACb,KAAK,GAsBN,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAA4E,MAAM,WAAW,CAAC;AAChK,OAAO,EAAE,UAAU,EAAkB,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../libs/map/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAqC,MAAM,aAAa,CAAC;AAE1E,OAAO,EACL,SAAS,EACT,UAAU,EACV,MAAM,EACN,aAAa,EACb,KAAK,GAsBN,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAA4E,MAAM,WAAW,CAAC;AAChK,OAAO,EAAE,UAAU,EAAkB,MAAM,cAAc,CAAC;AAG1D,+DAA+D;AAC/D,OAAO,EAAE,YAAY,EAA2C,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Locale } from '@fieldia/core';
|
|
2
|
+
import { type MapLabels } from './labels.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* The words of an address field that suggests addresses
|
|
5
|
+
* (`char.address-search`), and of its kind in the designer: in a module of
|
|
6
|
+
* their own, so a page that shows forms (and no designer) loads them with
|
|
7
|
+
* the field's suggestions, not before.
|
|
8
|
+
*/
|
|
9
|
+
export interface AddressLabels {
|
|
10
|
+
/** Said to screen readers as suggestions come: `{n}` how many. */
|
|
11
|
+
suggested: string;
|
|
12
|
+
addressKind: string;
|
|
13
|
+
/** The designer's settings: the field a picked address's place goes into, the field its parts go into, the country it keeps to. */
|
|
14
|
+
settingPlace: string;
|
|
15
|
+
settingParts: string;
|
|
16
|
+
settingCountry: string;
|
|
17
|
+
anywhere: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const ADDRESS_LABELS: Record<Locale, AddressLabels>;
|
|
20
|
+
/** An address field's words for a page's language, the maps' own with them, and the app's own over both. */
|
|
21
|
+
export declare function addressLabels(locale: Locale | undefined, own?: Partial<MapLabels & AddressLabels>): MapLabels & AddressLabels;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Locale } from '@fieldia/core';
|
|
2
|
+
import { type MapLabels } from './labels';
|
|
3
|
+
/**
|
|
4
|
+
* The words of an address field that suggests addresses
|
|
5
|
+
* (`char.address-search`), and of its kind in the designer: in a module of
|
|
6
|
+
* their own, so a page that shows forms (and no designer) loads them with
|
|
7
|
+
* the field's suggestions, not before.
|
|
8
|
+
*/
|
|
9
|
+
export interface AddressLabels {
|
|
10
|
+
/** Said to screen readers as suggestions come: `{n}` how many. */
|
|
11
|
+
suggested: string;
|
|
12
|
+
addressKind: string;
|
|
13
|
+
/** The designer's settings: the field a picked address's place goes into, the field its parts go into, the country it keeps to. */
|
|
14
|
+
settingPlace: string;
|
|
15
|
+
settingParts: string;
|
|
16
|
+
settingCountry: string;
|
|
17
|
+
anywhere: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const ADDRESS_LABELS: Record<Locale, AddressLabels>;
|
|
20
|
+
/** An address field's words for a page's language, the maps' own with them, and the app's own over both. */
|
|
21
|
+
export declare function addressLabels(locale: Locale | undefined, own?: Partial<MapLabels & AddressLabels>): MapLabels & AddressLabels;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ADDRESS_LABELS = void 0;
|
|
4
|
+
exports.addressLabels = addressLabels;
|
|
5
|
+
const labels_1 = require("./labels");
|
|
6
|
+
exports.ADDRESS_LABELS = {
|
|
7
|
+
en: { suggested: 'Suggestions: {n}', addressKind: 'Address search', settingPlace: 'Place goes into', settingParts: 'Parts go into', settingCountry: 'Addresses in', anywhere: 'Any country' },
|
|
8
|
+
ar: { suggested: 'الاقتراحات: {n}', addressKind: 'بحث عن عنوان', settingPlace: 'يُكتب المكان في', settingParts: 'تُكتب أجزاؤه في', settingCountry: 'العناوين في', anywhere: 'أي بلد' },
|
|
9
|
+
fr: { suggested: 'Suggestions : {n}', addressKind: 'Recherche d’adresse', settingPlace: 'Le lieu va dans', settingParts: 'Ses parties vont dans', settingCountry: 'Pays des adresses', anywhere: 'Tous les pays' },
|
|
10
|
+
de: { suggested: 'Vorschläge: {n}', addressKind: 'Adresssuche', settingPlace: 'Ort kommt in', settingParts: 'Teile kommen in', settingCountry: 'Land der Adressen', anywhere: 'Alle Länder' },
|
|
11
|
+
};
|
|
12
|
+
/** An address field's words for a page's language, the maps' own with them, and the app's own over both. */
|
|
13
|
+
function addressLabels(locale, own) {
|
|
14
|
+
return { ...labels_1.MAP_LABELS[locale ?? 'en'], ...exports.ADDRESS_LABELS[locale ?? 'en'], ...own };
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=address-labels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address-labels.js","sourceRoot":"","sources":["../../../../../libs/map/src/lib/address-labels.ts"],"names":[],"mappings":";;;AA4BA,sCAEC;AA7BD,qCAAsD;AAmBzC,QAAA,cAAc,GAAkC;IAC3D,EAAE,EAAE,EAAE,SAAS,EAAE,kBAAkB,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE;IAC7L,EAAE,EAAE,EAAE,SAAS,EAAE,iBAAiB,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE;IACtL,EAAE,EAAE,EAAE,SAAS,EAAE,mBAAmB,EAAE,WAAW,EAAE,qBAAqB,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,uBAAuB,EAAE,cAAc,EAAE,mBAAmB,EAAE,QAAQ,EAAE,eAAe,EAAE;IAClN,EAAE,EAAE,EAAE,SAAS,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,mBAAmB,EAAE,QAAQ,EAAE,aAAa,EAAE;CAC9L,CAAC;AAEF,4GAA4G;AAC5G,SAAgB,aAAa,CAAC,MAA0B,EAAE,GAAwC;IAChG,OAAO,EAAE,GAAG,mBAAU,CAAC,MAAM,IAAI,IAAI,CAAC,EAAE,GAAG,sBAAc,CAAC,MAAM,IAAI,IAAI,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC;AACtF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MAP_LABELS } from './labels.mjs';
|
|
2
|
+
export const ADDRESS_LABELS = {
|
|
3
|
+
en: { suggested: 'Suggestions: {n}', addressKind: 'Address search', settingPlace: 'Place goes into', settingParts: 'Parts go into', settingCountry: 'Addresses in', anywhere: 'Any country' },
|
|
4
|
+
ar: { suggested: 'الاقتراحات: {n}', addressKind: 'بحث عن عنوان', settingPlace: 'يُكتب المكان في', settingParts: 'تُكتب أجزاؤه في', settingCountry: 'العناوين في', anywhere: 'أي بلد' },
|
|
5
|
+
fr: { suggested: 'Suggestions : {n}', addressKind: 'Recherche d’adresse', settingPlace: 'Le lieu va dans', settingParts: 'Ses parties vont dans', settingCountry: 'Pays des adresses', anywhere: 'Tous les pays' },
|
|
6
|
+
de: { suggested: 'Vorschläge: {n}', addressKind: 'Adresssuche', settingPlace: 'Ort kommt in', settingParts: 'Teile kommen in', settingCountry: 'Land der Adressen', anywhere: 'Alle Länder' },
|
|
7
|
+
};
|
|
8
|
+
/** An address field's words for a page's language, the maps' own with them, and the app's own over both. */
|
|
9
|
+
export function addressLabels(locale, own) {
|
|
10
|
+
return { ...MAP_LABELS[locale ?? 'en'], ...ADDRESS_LABELS[locale ?? 'en'], ...own };
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=address-labels.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address-labels.mjs","sourceRoot":"","sources":["../../../../../libs/map/src/lib/address-labels.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAkB,MAAM,UAAU,CAAC;AAmBtD,MAAM,CAAC,MAAM,cAAc,GAAkC;IAC3D,EAAE,EAAE,EAAE,SAAS,EAAE,kBAAkB,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE;IAC7L,EAAE,EAAE,EAAE,SAAS,EAAE,iBAAiB,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE;IACtL,EAAE,EAAE,EAAE,SAAS,EAAE,mBAAmB,EAAE,WAAW,EAAE,qBAAqB,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,uBAAuB,EAAE,cAAc,EAAE,mBAAmB,EAAE,QAAQ,EAAE,eAAe,EAAE;IAClN,EAAE,EAAE,EAAE,SAAS,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,mBAAmB,EAAE,QAAQ,EAAE,aAAa,EAAE;CAC9L,CAAC;AAEF,4GAA4G;AAC5G,MAAM,UAAU,aAAa,CAAC,MAA0B,EAAE,GAAwC;IAChG,OAAO,EAAE,GAAG,UAAU,CAAC,MAAM,IAAI,IAAI,CAAC,EAAE,GAAG,cAAc,CAAC,MAAM,IAAI,IAAI,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC;AACtF,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addressLine = addressLine;
|
|
4
|
+
/**
|
|
5
|
+
* An address on one line, as a field keeps it and a suggestion's second line
|
|
6
|
+
* shows it: its pieces in order (a name or a street, then where it is), each
|
|
7
|
+
* said once, joined as the page's language joins them, "، " in Arabic and
|
|
8
|
+
* ", " in the others. A piece is cut where a provider put its own commas, and
|
|
9
|
+
* left out when it repeats one said before it: the same words ("Cairo",
|
|
10
|
+
* "Cairo"), or a wider place named after it ("Cairo Governorate" after
|
|
11
|
+
* "Cairo", "محافظة القاهرة" after "القاهرة") unless it carries a number of
|
|
12
|
+
* its own, a postcode. A narrower piece holding a wider one's name, a street
|
|
13
|
+
* named after its city, stays: it was said first.
|
|
14
|
+
*/
|
|
15
|
+
const MARKS = /[--]/g;
|
|
16
|
+
const words = (piece) => piece.toLowerCase().split(/\s+/);
|
|
17
|
+
/** Whether `few` are in `many`, one after another, as whole words. */
|
|
18
|
+
const within = (few, many) => many.some((_, at) => few.every((word, i) => many[at + i] === word));
|
|
19
|
+
function addressLine(pieces, locale) {
|
|
20
|
+
const said = [];
|
|
21
|
+
const kept = [];
|
|
22
|
+
for (const piece of pieces.flatMap((p) => (typeof p === 'string' ? p.replace(MARKS, '').split(/[,،]/) : []))) {
|
|
23
|
+
const text = piece.trim();
|
|
24
|
+
if (!text)
|
|
25
|
+
continue;
|
|
26
|
+
const these = words(text);
|
|
27
|
+
if (said.some((before) => within(before, these) && (before.length === these.length || !/\p{Nd}/u.test(text))))
|
|
28
|
+
continue;
|
|
29
|
+
said.push(these);
|
|
30
|
+
kept.push(text);
|
|
31
|
+
}
|
|
32
|
+
return kept.join(locale === 'ar' ? '، ' : ', ');
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=address-line.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address-line.js","sourceRoot":"","sources":["../../../../../libs/map/src/lib/address-line.ts"],"names":[],"mappings":";;AAmBA,kCAYC;AA7BD;;;;;;;;;;GAUG;AAEH,MAAM,KAAK,GAAG,cAAc,CAAC;AAC7B,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAClE,sEAAsE;AACtE,MAAM,MAAM,GAAG,CAAC,GAAa,EAAE,IAAc,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;AAEtH,SAAgB,WAAW,CAAC,MAAiB,EAAE,MAAe;IAC5D,MAAM,IAAI,GAAe,EAAE,CAAC;IAC5B,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;QAC7G,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC,IAAI;YAAE,SAAS;QACpB,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1B,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YAAE,SAAS;QACxH,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACjB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An address on one line, as a field keeps it and a suggestion's second line
|
|
3
|
+
* shows it: its pieces in order (a name or a street, then where it is), each
|
|
4
|
+
* said once, joined as the page's language joins them, "، " in Arabic and
|
|
5
|
+
* ", " in the others. A piece is cut where a provider put its own commas, and
|
|
6
|
+
* left out when it repeats one said before it: the same words ("Cairo",
|
|
7
|
+
* "Cairo"), or a wider place named after it ("Cairo Governorate" after
|
|
8
|
+
* "Cairo", "محافظة القاهرة" after "القاهرة") unless it carries a number of
|
|
9
|
+
* its own, a postcode. A narrower piece holding a wider one's name, a street
|
|
10
|
+
* named after its city, stays: it was said first.
|
|
11
|
+
*/
|
|
12
|
+
const MARKS = /[--]/g;
|
|
13
|
+
const words = (piece) => piece.toLowerCase().split(/\s+/);
|
|
14
|
+
/** Whether `few` are in `many`, one after another, as whole words. */
|
|
15
|
+
const within = (few, many) => many.some((_, at) => few.every((word, i) => many[at + i] === word));
|
|
16
|
+
export function addressLine(pieces, locale) {
|
|
17
|
+
const said = [];
|
|
18
|
+
const kept = [];
|
|
19
|
+
for (const piece of pieces.flatMap((p) => (typeof p === 'string' ? p.replace(MARKS, '').split(/[,،]/) : []))) {
|
|
20
|
+
const text = piece.trim();
|
|
21
|
+
if (!text)
|
|
22
|
+
continue;
|
|
23
|
+
const these = words(text);
|
|
24
|
+
if (said.some((before) => within(before, these) && (before.length === these.length || !/\p{Nd}/u.test(text))))
|
|
25
|
+
continue;
|
|
26
|
+
said.push(these);
|
|
27
|
+
kept.push(text);
|
|
28
|
+
}
|
|
29
|
+
return kept.join(locale === 'ar' ? '، ' : ', ');
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=address-line.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address-line.mjs","sourceRoot":"","sources":["../../../../../libs/map/src/lib/address-line.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAEH,MAAM,KAAK,GAAG,cAAc,CAAC;AAC7B,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAClE,sEAAsE;AACtE,MAAM,MAAM,GAAG,CAAC,GAAa,EAAE,IAAc,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;AAEtH,MAAM,UAAU,WAAW,CAAC,MAAiB,EAAE,MAAe;IAC5D,MAAM,IAAI,GAAe,EAAE,CAAC;IAC5B,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;QAC7G,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC,IAAI;YAAE,SAAS;QACpB,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1B,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YAAE,SAAS;QACxH,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACjB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An address in its parts, as Fieldia's address field (`json.address`) keeps
|
|
3
|
+
* one: the street with its number, the city, the region (a state, a
|
|
4
|
+
* governorate), the postcode, and the country as its ISO code ("EG"). Each
|
|
5
|
+
* provider names them its own way; they are read into these here, asked for
|
|
6
|
+
* only by a search that wants them (`SearchRequest.parts`).
|
|
7
|
+
*/
|
|
8
|
+
export interface AddressParts {
|
|
9
|
+
street?: string;
|
|
10
|
+
city?: string;
|
|
11
|
+
region?: string;
|
|
12
|
+
postcode?: string;
|
|
13
|
+
country?: string;
|
|
14
|
+
}
|
|
15
|
+
/** Photon's properties: a street, or a city, may be the place itself. */
|
|
16
|
+
export declare const photonParts: (p: unknown) => AddressParts | undefined;
|
|
17
|
+
/** Nominatim's `address` (with `addressdetails=1`): a town or a village where there is no city. */
|
|
18
|
+
export declare const nominatimParts: (a: unknown) => AddressParts | undefined;
|
|
19
|
+
/** Azure's `address`: its own street line when it has one, its first admin district the region; its country's code is `ISO`, or `iso` in some answers. */
|
|
20
|
+
export declare const azureParts: (a: unknown) => AddressParts | undefined;
|
|
21
|
+
/** Google's `addressComponents`, each by its type: the country by its short code. */
|
|
22
|
+
export declare const googleParts: (components: unknown) => AddressParts | undefined;
|
|
23
|
+
/** Mapbox's `context`: its address's own line (number and street), or the street alone. */
|
|
24
|
+
export declare const mapboxParts: (p: unknown) => AddressParts | undefined;
|
|
25
|
+
/** Only places in the countries asked for, when some are: for a provider that cannot be asked to keep to them. */
|
|
26
|
+
export declare const inCountries: <T extends {
|
|
27
|
+
parts?: AddressParts;
|
|
28
|
+
}>(places: T[], countries?: string[]) => T[];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An address in its parts, as Fieldia's address field (`json.address`) keeps
|
|
3
|
+
* one: the street with its number, the city, the region (a state, a
|
|
4
|
+
* governorate), the postcode, and the country as its ISO code ("EG"). Each
|
|
5
|
+
* provider names them its own way; they are read into these here, asked for
|
|
6
|
+
* only by a search that wants them (`SearchRequest.parts`).
|
|
7
|
+
*/
|
|
8
|
+
export interface AddressParts {
|
|
9
|
+
street?: string;
|
|
10
|
+
city?: string;
|
|
11
|
+
region?: string;
|
|
12
|
+
postcode?: string;
|
|
13
|
+
country?: string;
|
|
14
|
+
}
|
|
15
|
+
/** Photon's properties: a street, or a city, may be the place itself. */
|
|
16
|
+
export declare const photonParts: (p: unknown) => AddressParts | undefined;
|
|
17
|
+
/** Nominatim's `address` (with `addressdetails=1`): a town or a village where there is no city. */
|
|
18
|
+
export declare const nominatimParts: (a: unknown) => AddressParts | undefined;
|
|
19
|
+
/** Azure's `address`: its own street line when it has one, its first admin district the region; its country's code is `ISO`, or `iso` in some answers. */
|
|
20
|
+
export declare const azureParts: (a: unknown) => AddressParts | undefined;
|
|
21
|
+
/** Google's `addressComponents`, each by its type: the country by its short code. */
|
|
22
|
+
export declare const googleParts: (components: unknown) => AddressParts | undefined;
|
|
23
|
+
/** Mapbox's `context`: its address's own line (number and street), or the street alone. */
|
|
24
|
+
export declare const mapboxParts: (p: unknown) => AddressParts | undefined;
|
|
25
|
+
/** Only places in the countries asked for, when some are: for a provider that cannot be asked to keep to them. */
|
|
26
|
+
export declare const inCountries: <T extends {
|
|
27
|
+
parts?: AddressParts;
|
|
28
|
+
}>(places: T[], countries?: string[]) => T[];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.inCountries = exports.mapboxParts = exports.googleParts = exports.azureParts = exports.nominatimParts = exports.photonParts = void 0;
|
|
4
|
+
const answers_1 = require("./answers");
|
|
5
|
+
/** Words without the direction marks Azure and Google put in Arabic. */
|
|
6
|
+
const text = (value) => (typeof value === 'string' ? value.replace(/[--]/g, '').trim() : '');
|
|
7
|
+
/** The parts there are, the street with its number after it (as a place's name has it), the country's code in capitals; nothing when none is. */
|
|
8
|
+
function partsOf(street, number, city, region, postcode, country) {
|
|
9
|
+
const found = {
|
|
10
|
+
street: [text(street), text(street) && text(number)].filter(Boolean).join(' '),
|
|
11
|
+
city: text(city),
|
|
12
|
+
region: text(region),
|
|
13
|
+
postcode: text(postcode),
|
|
14
|
+
country: text(country).toUpperCase(),
|
|
15
|
+
};
|
|
16
|
+
const parts = Object.fromEntries(Object.entries(found).filter(([, value]) => value));
|
|
17
|
+
return Object.keys(parts).length ? parts : undefined;
|
|
18
|
+
}
|
|
19
|
+
/** Photon's properties: a street, or a city, may be the place itself. */
|
|
20
|
+
const photonParts = (p) => {
|
|
21
|
+
const kind = (0, answers_1.pathOf)(p, 'type');
|
|
22
|
+
const own = (as) => (kind === as ? (0, answers_1.pathOf)(p, 'name') : undefined);
|
|
23
|
+
return partsOf((0, answers_1.pathOf)(p, 'street') ?? own('street'), (0, answers_1.pathOf)(p, 'housenumber'), (0, answers_1.pathOf)(p, 'city') ?? own('city'), (0, answers_1.pathOf)(p, 'state'), (0, answers_1.pathOf)(p, 'postcode'), (0, answers_1.pathOf)(p, 'countrycode'));
|
|
24
|
+
};
|
|
25
|
+
exports.photonParts = photonParts;
|
|
26
|
+
/** Nominatim's `address` (with `addressdetails=1`): a town or a village where there is no city. */
|
|
27
|
+
const nominatimParts = (a) => partsOf((0, answers_1.pathOf)(a, 'road'), (0, answers_1.pathOf)(a, 'house_number'), (0, answers_1.pathOf)(a, 'city') ?? (0, answers_1.pathOf)(a, 'town') ?? (0, answers_1.pathOf)(a, 'village'), (0, answers_1.pathOf)(a, 'state'), (0, answers_1.pathOf)(a, 'postcode'), (0, answers_1.pathOf)(a, 'country_code'));
|
|
28
|
+
exports.nominatimParts = nominatimParts;
|
|
29
|
+
/** Azure's `address`: its own street line when it has one, its first admin district the region; its country's code is `ISO`, or `iso` in some answers. */
|
|
30
|
+
const azureParts = (a) => partsOf(text((0, answers_1.pathOf)(a, 'addressLine')) || (0, answers_1.pathOf)(a, 'streetName'), text((0, answers_1.pathOf)(a, 'addressLine')) ? '' : (0, answers_1.pathOf)(a, 'streetNumber'), (0, answers_1.pathOf)(a, 'locality'), (0, answers_1.pathOf)(a, 'adminDistricts')?.map((d) => text((0, answers_1.pathOf)(d, 'name')) || (0, answers_1.pathOf)(d, 'shortName'))[0], (0, answers_1.pathOf)(a, 'postalCode'), (0, answers_1.pathOf)(a, 'countryRegion', 'ISO') ?? (0, answers_1.pathOf)(a, 'countryRegion', 'iso'));
|
|
31
|
+
exports.azureParts = azureParts;
|
|
32
|
+
/** Google's `addressComponents`, each by its type: the country by its short code. */
|
|
33
|
+
const googleParts = (components) => {
|
|
34
|
+
const of = (type, short) => (0, answers_1.pathOf)((Array.isArray(components) ? components : []).find((c) => (0, answers_1.pathOf)(c, 'types')?.includes(type)), short ? 'shortText' : 'longText');
|
|
35
|
+
return partsOf(of('route'), of('street_number'), of('locality') ?? of('postal_town'), of('administrative_area_level_1'), of('postal_code'), of('country', true));
|
|
36
|
+
};
|
|
37
|
+
exports.googleParts = googleParts;
|
|
38
|
+
/** Mapbox's `context`: its address's own line (number and street), or the street alone. */
|
|
39
|
+
const mapboxParts = (p) => {
|
|
40
|
+
const at = (...path) => (0, answers_1.pathOf)(p, 'context', ...path);
|
|
41
|
+
return partsOf(at('address', 'name') ?? at('street', 'name'), '', at('place', 'name') ?? at('locality', 'name'), at('region', 'name'), at('postcode', 'name'), at('country', 'country_code'));
|
|
42
|
+
};
|
|
43
|
+
exports.mapboxParts = mapboxParts;
|
|
44
|
+
/** Only places in the countries asked for, when some are: for a provider that cannot be asked to keep to them. */
|
|
45
|
+
const inCountries = (places, countries) => countries?.length ? places.filter((place) => countries.includes(place.parts?.country ?? '')) : places;
|
|
46
|
+
exports.inCountries = inCountries;
|
|
47
|
+
//# sourceMappingURL=address-parts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address-parts.js","sourceRoot":"","sources":["../../../../../libs/map/src/lib/address-parts.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AAiBnC,wEAAwE;AACxE,MAAM,IAAI,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAE7G,iJAAiJ;AACjJ,SAAS,OAAO,CAAC,MAAe,EAAE,MAAe,EAAE,IAAa,EAAE,MAAe,EAAE,QAAiB,EAAE,OAAgB;IACpH,MAAM,KAAK,GAA2B;QACpC,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC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SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC;AAChM,CAAC,CAAC;AAHW,QAAA,WAAW,eAGtB;AAEF,kHAAkH;AAC3G,MAAM,WAAW,GAAG,CAAqC,MAAW,EAAE,SAAoB,EAAE,EAAE,CACnG,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAD3F,QAAA,WAAW,eACgF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { pathOf } from './answers.mjs';
|
|
2
|
+
/** Words without the direction marks Azure and Google put in Arabic. */
|
|
3
|
+
const text = (value) => (typeof value === 'string' ? value.replace(/[--]/g, '').trim() : '');
|
|
4
|
+
/** The parts there are, the street with its number after it (as a place's name has it), the country's code in capitals; nothing when none is. */
|
|
5
|
+
function partsOf(street, number, city, region, postcode, country) {
|
|
6
|
+
const found = {
|
|
7
|
+
street: [text(street), text(street) && text(number)].filter(Boolean).join(' '),
|
|
8
|
+
city: text(city),
|
|
9
|
+
region: text(region),
|
|
10
|
+
postcode: text(postcode),
|
|
11
|
+
country: text(country).toUpperCase(),
|
|
12
|
+
};
|
|
13
|
+
const parts = Object.fromEntries(Object.entries(found).filter(([, value]) => value));
|
|
14
|
+
return Object.keys(parts).length ? parts : undefined;
|
|
15
|
+
}
|
|
16
|
+
/** Photon's properties: a street, or a city, may be the place itself. */
|
|
17
|
+
export const photonParts = (p) => {
|
|
18
|
+
const kind = pathOf(p, 'type');
|
|
19
|
+
const own = (as) => (kind === as ? pathOf(p, 'name') : undefined);
|
|
20
|
+
return partsOf(pathOf(p, 'street') ?? own('street'), pathOf(p, 'housenumber'), pathOf(p, 'city') ?? own('city'), pathOf(p, 'state'), pathOf(p, 'postcode'), pathOf(p, 'countrycode'));
|
|
21
|
+
};
|
|
22
|
+
/** Nominatim's `address` (with `addressdetails=1`): a town or a village where there is no city. */
|
|
23
|
+
export const nominatimParts = (a) => partsOf(pathOf(a, 'road'), pathOf(a, 'house_number'), pathOf(a, 'city') ?? pathOf(a, 'town') ?? pathOf(a, 'village'), pathOf(a, 'state'), pathOf(a, 'postcode'), pathOf(a, 'country_code'));
|
|
24
|
+
/** Azure's `address`: its own street line when it has one, its first admin district the region; its country's code is `ISO`, or `iso` in some answers. */
|
|
25
|
+
export const azureParts = (a) => partsOf(text(pathOf(a, 'addressLine')) || pathOf(a, 'streetName'), text(pathOf(a, 'addressLine')) ? '' : pathOf(a, 'streetNumber'), pathOf(a, 'locality'), pathOf(a, 'adminDistricts')?.map((d) => text(pathOf(d, 'name')) || pathOf(d, 'shortName'))[0], pathOf(a, 'postalCode'), pathOf(a, 'countryRegion', 'ISO') ?? pathOf(a, 'countryRegion', 'iso'));
|
|
26
|
+
/** Google's `addressComponents`, each by its type: the country by its short code. */
|
|
27
|
+
export const googleParts = (components) => {
|
|
28
|
+
const of = (type, short) => pathOf((Array.isArray(components) ? components : []).find((c) => pathOf(c, 'types')?.includes(type)), short ? 'shortText' : 'longText');
|
|
29
|
+
return partsOf(of('route'), of('street_number'), of('locality') ?? of('postal_town'), of('administrative_area_level_1'), of('postal_code'), of('country', true));
|
|
30
|
+
};
|
|
31
|
+
/** Mapbox's `context`: its address's own line (number and street), or the street alone. */
|
|
32
|
+
export const mapboxParts = (p) => {
|
|
33
|
+
const at = (...path) => pathOf(p, 'context', ...path);
|
|
34
|
+
return partsOf(at('address', 'name') ?? at('street', 'name'), '', at('place', 'name') ?? at('locality', 'name'), at('region', 'name'), at('postcode', 'name'), at('country', 'country_code'));
|
|
35
|
+
};
|
|
36
|
+
/** Only places in the countries asked for, when some are: for a provider that cannot be asked to keep to them. */
|
|
37
|
+
export const inCountries = (places, countries) => countries?.length ? places.filter((place) => countries.includes(place.parts?.country ?? '')) : places;
|
|
38
|
+
//# sourceMappingURL=address-parts.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address-parts.mjs","sourceRoot":"","sources":["../../../../../libs/map/src/lib/address-parts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAiBnC,wEAAwE;AACxE,MAAM,IAAI,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAE7G,iJAAiJ;AACjJ,SAAS,OAAO,CAAC,MAAe,EAAE,MAAe,EAAE,IAAa,EAAE,MAAe,EAAE,QAAiB,EAAE,OAAgB;IACpH,MAAM,KAAK,GAA2B;QACpC,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAC9E,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC;QAChB,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;QACpB,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC;QACxB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE;KACrC,CAAC;IACF,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CA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
|
|
|
1
|
+
import { type WidgetFactory } from '@fieldia/widgets';
|
|
2
|
+
import type { MapSettings } from './settings.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* An address typed on one line (`"widget": "address-search"` on a char
|
|
5
|
+
* field), the addresses the map's provider suggests as people type in a list
|
|
6
|
+
* under it, and no map: the place search's own combobox, its pauses, its
|
|
7
|
+
* credits and its language. What is typed is the answer when nothing is
|
|
8
|
+
* picked. A suggestion picked writes its whole address, and where the page
|
|
9
|
+
* says, its place into a place field (`placeField`: a json field's GeoJSON
|
|
10
|
+
* Point, or a float field's latitude with `longitudeField` for its
|
|
11
|
+
* longitude) and its parts into an address field (`partsField`, a
|
|
12
|
+
* `json.address`: street, city, region, postcode and country, the line under
|
|
13
|
+
* the street kept as typed). `countries` (ISO codes) keeps the suggestions to
|
|
14
|
+
* those countries; `near` (`{ "lat", "lng" }`) puts those near it first, as
|
|
15
|
+
* where the app's maps open does unless it says.
|
|
16
|
+
*
|
|
17
|
+
* The box is the app's own text box, there at once; the suggestions come
|
|
18
|
+
* with their code, loaded the first time an address field is shown. With no
|
|
19
|
+
* address search to ask, the text box is all there is.
|
|
20
|
+
*/
|
|
21
|
+
export declare function addressSearchWidget(settings: MapSettings): WidgetFactory;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type WidgetFactory } from '@fieldia/widgets';
|
|
2
|
+
import type { MapSettings } from './settings';
|
|
3
|
+
/**
|
|
4
|
+
* An address typed on one line (`"widget": "address-search"` on a char
|
|
5
|
+
* field), the addresses the map's provider suggests as people type in a list
|
|
6
|
+
* under it, and no map: the place search's own combobox, its pauses, its
|
|
7
|
+
* credits and its language. What is typed is the answer when nothing is
|
|
8
|
+
* picked. A suggestion picked writes its whole address, and where the page
|
|
9
|
+
* says, its place into a place field (`placeField`: a json field's GeoJSON
|
|
10
|
+
* Point, or a float field's latitude with `longitudeField` for its
|
|
11
|
+
* longitude) and its parts into an address field (`partsField`, a
|
|
12
|
+
* `json.address`: street, city, region, postcode and country, the line under
|
|
13
|
+
* the street kept as typed). `countries` (ISO codes) keeps the suggestions to
|
|
14
|
+
* those countries; `near` (`{ "lat", "lng" }`) puts those near it first, as
|
|
15
|
+
* where the app's maps open does unless it says.
|
|
16
|
+
*
|
|
17
|
+
* The box is the app's own text box, there at once; the suggestions come
|
|
18
|
+
* with their code, loaded the first time an address field is shown. With no
|
|
19
|
+
* address search to ask, the text box is all there is.
|
|
20
|
+
*/
|
|
21
|
+
export declare function addressSearchWidget(settings: MapSettings): WidgetFactory;
|