@fieldia/map 0.14.1 → 0.16.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 +103 -10
- package/package.json +5 -4
- package/src/index.d.mts +5 -1
- package/src/index.d.ts +5 -1
- package/src/index.js +7 -1
- package/src/index.js.map +1 -1
- package/src/index.mjs +3 -0
- package/src/index.mjs.map +1 -1
- package/src/lib/answers.d.mts +17 -0
- package/src/lib/answers.d.ts +17 -0
- package/src/lib/answers.js +27 -0
- package/src/lib/answers.js.map +1 -0
- package/src/lib/answers.mjs +21 -0
- package/src/lib/answers.mjs.map +1 -0
- package/src/lib/area.js +29 -246
- package/src/lib/area.js.map +1 -1
- package/src/lib/area.mjs +29 -246
- package/src/lib/area.mjs.map +1 -1
- package/src/lib/card.d.mts +53 -0
- package/src/lib/card.d.ts +53 -0
- package/src/lib/card.js +98 -0
- package/src/lib/card.js.map +1 -0
- package/src/lib/card.mjs +94 -0
- package/src/lib/card.mjs.map +1 -0
- package/src/lib/cluster.d.mts +12 -0
- package/src/lib/cluster.d.ts +12 -0
- package/src/lib/cluster.js +60 -0
- package/src/lib/cluster.js.map +1 -0
- package/src/lib/cluster.mjs +57 -0
- package/src/lib/cluster.mjs.map +1 -0
- package/src/lib/drawing.d.mts +36 -0
- package/src/lib/drawing.d.ts +36 -0
- package/src/lib/drawing.js +267 -0
- package/src/lib/drawing.js.map +1 -0
- package/src/lib/drawing.mjs +263 -0
- package/src/lib/drawing.mjs.map +1 -0
- package/src/lib/form-map.d.mts +16 -0
- package/src/lib/form-map.d.ts +16 -0
- package/src/lib/form-map.js +525 -0
- package/src/lib/form-map.js.map +1 -0
- package/src/lib/form-map.mjs +522 -0
- package/src/lib/form-map.mjs.map +1 -0
- package/src/lib/kinds.js +9 -2
- package/src/lib/kinds.js.map +1 -1
- package/src/lib/kinds.mjs +9 -2
- package/src/lib/kinds.mjs.map +1 -1
- package/src/lib/labels.d.mts +41 -0
- package/src/lib/labels.d.ts +41 -0
- package/src/lib/labels.js +87 -1
- package/src/lib/labels.js.map +1 -1
- package/src/lib/labels.mjs +84 -0
- package/src/lib/labels.mjs.map +1 -1
- package/src/lib/list-view.d.mts +13 -0
- package/src/lib/list-view.d.ts +13 -0
- package/src/lib/list-view.js +464 -0
- package/src/lib/list-view.js.map +1 -0
- package/src/lib/list-view.mjs +461 -0
- package/src/lib/list-view.mjs.map +1 -0
- package/src/lib/map-core.d.mts +2 -2
- package/src/lib/map-core.d.ts +2 -2
- package/src/lib/map-core.js +23 -3
- package/src/lib/map-core.js.map +1 -1
- package/src/lib/map-core.mjs +23 -3
- package/src/lib/map-core.mjs.map +1 -1
- package/src/lib/map-icons.d.mts +8 -0
- package/src/lib/map-icons.d.ts +8 -0
- package/src/lib/map-icons.js +21 -0
- package/src/lib/map-icons.js.map +1 -0
- package/src/lib/map-icons.mjs +18 -0
- package/src/lib/map-icons.mjs.map +1 -0
- package/src/lib/marks.d.mts +34 -0
- package/src/lib/marks.d.ts +34 -0
- package/src/lib/marks.js +56 -0
- package/src/lib/marks.js.map +1 -0
- package/src/lib/marks.mjs +49 -0
- package/src/lib/marks.mjs.map +1 -0
- package/src/lib/pins.d.mts +58 -0
- package/src/lib/pins.d.ts +58 -0
- package/src/lib/pins.js +165 -0
- package/src/lib/pins.js.map +1 -0
- package/src/lib/pins.mjs +156 -0
- package/src/lib/pins.mjs.map +1 -0
- package/src/lib/providers.d.mts +27 -3
- package/src/lib/providers.d.ts +27 -3
- package/src/lib/providers.js +69 -67
- package/src/lib/providers.js.map +1 -1
- package/src/lib/providers.mjs +17 -15
- package/src/lib/providers.mjs.map +1 -1
- package/src/lib/route-line.d.mts +34 -0
- package/src/lib/route-line.d.ts +34 -0
- package/src/lib/route-line.js +53 -0
- package/src/lib/route-line.js.map +1 -0
- package/src/lib/route-line.mjs +47 -0
- package/src/lib/route-line.mjs.map +1 -0
- package/src/lib/routes.d.mts +28 -0
- package/src/lib/routes.d.ts +28 -0
- package/src/lib/routes.js +112 -0
- package/src/lib/routes.js.map +1 -0
- package/src/lib/routes.mjs +105 -0
- package/src/lib/routes.mjs.map +1 -0
- package/src/lib/settings.d.mts +8 -3
- package/src/lib/settings.d.ts +8 -3
- package/src/lib/styles.d.mts +16 -0
- package/src/lib/styles.d.ts +16 -0
- package/src/lib/styles.js +181 -1
- package/src/lib/styles.js.map +1 -1
- package/src/lib/styles.mjs +178 -0
- package/src/lib/styles.mjs.map +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# @fieldia/map
|
|
2
2
|
|
|
3
3
|
[Fieldia](https://fieldia.dev)'s maps: a **place** and an **area** as fields of a
|
|
4
|
-
form, on
|
|
5
|
-
|
|
4
|
+
form, a **list's records on a map**, and a **map on a form** with its layers,
|
|
5
|
+
places that move and routes along the roads, on the map provider you choose.
|
|
6
|
+
Built on [Leaflet](https://leafletjs.com), loaded only when a map is shown.
|
|
6
7
|
|
|
7
8
|
```sh
|
|
8
9
|
npm install @fieldia/map
|
|
@@ -53,6 +54,88 @@ the whole area drags to move it, and a point between two adds one.
|
|
|
53
54
|
Options: `shapes` (any of polygon, box, circle), `areas` (named areas to choose
|
|
54
55
|
instead of drawing), `height`.
|
|
55
56
|
|
|
57
|
+
## A list on a map
|
|
58
|
+
|
|
59
|
+
A list page with `map` shows its records on a map too, beside the table or
|
|
60
|
+
instead of it, sharing its search and its records chosen: a pin lights its row
|
|
61
|
+
and a row its pin, a pin opens a card (a picture, a few fields, Choose, Open),
|
|
62
|
+
pins that crowd become a bubble with their count, and "Search this area" puts
|
|
63
|
+
the map's view into the search bar.
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { mapListViews, azureMaps } from '@fieldia/map';
|
|
67
|
+
|
|
68
|
+
mountViewer(host, { page, dataSource, listViews: mapListViews({ provider: azureMaps({ key }) }) });
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
"map": {
|
|
73
|
+
"latitude": "lat", "longitude": "lng",
|
|
74
|
+
"pin": { "label": "price", "tones": [{ "tone": "info", "when": "offer == 'rent'" }] },
|
|
75
|
+
"card": { "title": "name", "image": "photo", "fields": ["price", "bedrooms"] },
|
|
76
|
+
"view": "both"
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Where each record is: `point` (a json field holding a GeoJSON Point), or
|
|
81
|
+
`latitude` and `longitude`. A pin's `look` is `pin`, `label`, `icon`, `photo`
|
|
82
|
+
or `dot`; `label` names the field it says (an amount or a number written short,
|
|
83
|
+
"E£9.5M"), `icon` or `iconField` its icon (the map's own car, arrow, scooter,
|
|
84
|
+
bike, bus, person, shop, food and flag, Fieldia's, or the app's `icons`),
|
|
85
|
+
`image` its photo, `turn` a number field in degrees (a car seen from above
|
|
86
|
+
turns whole; other icons keep upright, a pointer on their edge turning), and
|
|
87
|
+
`tones` its colour by condition. `widget` names the app's own pin, given as
|
|
88
|
+
`mapListViews({ pins: { name: (record, { document }) => element } })`. `card`
|
|
89
|
+
takes `title`, `image`, `fields` and `open`; `cluster: false` draws every pin
|
|
90
|
+
on its own, though pins near one another then overlap and a pointer cannot
|
|
91
|
+
reach one under another (the keys still reach each); `view` is `list`, `map` or `both`; `limit` is 500 unless said.
|
|
92
|
+
|
|
93
|
+
The map's own tools draw an area to search in: a polygon, a box or a circle,
|
|
94
|
+
by mouse, finger or keys, as the area field draws one. It becomes a search of
|
|
95
|
+
its own ("In the area drawn"), shown on the map until it leaves the search bar.
|
|
96
|
+
|
|
97
|
+
"Search this area" asks for `between` on a latitude and a longitude, or the
|
|
98
|
+
`within` condition on a point: `{ south, west, north, east }` in degrees, west
|
|
99
|
+
beyond east across the antimeridian. An area drawn asks for `within` with
|
|
100
|
+
`{ polygon: [[lng, lat], …] }` or `{ center: [lng, lat], radius }` in metres;
|
|
101
|
+
on a latitude field, `longitude` names the field of its longitude. The memory
|
|
102
|
+
data source answers all of them; a server's adapter turns them into its own
|
|
103
|
+
query.
|
|
104
|
+
|
|
105
|
+
A form with only a place or an area never carries the list map's code, its
|
|
106
|
+
styles or its words.
|
|
107
|
+
|
|
108
|
+
A card offers the list's own buttons too, each pressed for its record alone
|
|
109
|
+
("Assign", for this driver).
|
|
110
|
+
|
|
111
|
+
## A map on a form
|
|
112
|
+
|
|
113
|
+
A part of type `map` shows the record's places as layers: the record's own
|
|
114
|
+
place (`point`, or `latitude` and `longitude`), a place for each of its lines
|
|
115
|
+
(`lines`, read from the line's fields), a `route` between them, or the
|
|
116
|
+
reader's own place (`myLocation`). Give the viewer `maps: mapParts(settings)`.
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
{ "type": "map", "id": "order-map", "label": "Where your order is", "layers": [
|
|
120
|
+
{ "id": "door", "label": "Your door", "point": "door", "pin": { "look": "icon", "icon": "home" } },
|
|
121
|
+
{ "id": "courier", "label": "Courier", "latitude": "courier_lat", "longitude": "courier_lng",
|
|
122
|
+
"pin": { "look": "photo", "image": "courier_photo", "label": "eta_text" },
|
|
123
|
+
"live": { "staleAfter": 60, "follow": true } },
|
|
124
|
+
{ "id": "way", "route": { "from": "courier", "to": "door", "progress": true,
|
|
125
|
+
"write": { "seconds": "eta_seconds", "metres": "distance_m", "line": "route_line" } } }
|
|
126
|
+
] }
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
A place that moves glides to each new place its fields are given (along its
|
|
130
|
+
route when on it), greys and says when it was last seen after `staleAfter`
|
|
131
|
+
seconds without news, and with `follow` is kept in view until the person moves
|
|
132
|
+
the map. A route runs `from` a place `to` another or `through` a layer of
|
|
133
|
+
lines, by `car`, `bike` or `foot`; with `progress` the part travelled fades and
|
|
134
|
+
the time and distance left are kept up to date; `write` names the fields its
|
|
135
|
+
seconds, metres and line go into. Routes come from the provider (`route`),
|
|
136
|
+
loaded the first time one is asked for, or from the app's own `route` in the
|
|
137
|
+
settings.
|
|
138
|
+
|
|
56
139
|
## Without a mouse
|
|
57
140
|
|
|
58
141
|
Tab reaches the map, which shows a cross at its centre: the arrow keys move the
|
|
@@ -63,15 +146,19 @@ arrow keys and leaves with Delete. A scroll passes over a map to the page
|
|
|
63
146
|
unless Ctrl (⌘) is held, and on a phone one finger scrolls the page while two
|
|
64
147
|
move the map.
|
|
65
148
|
|
|
149
|
+
On a list's map, Tab goes from the map to each pin and bubble by its name;
|
|
150
|
+
Enter or Space opens a pin's card (Ctrl or ⌘ with it chooses the record) or
|
|
151
|
+
zooms into a bubble, and Escape closes the card, back on its pin.
|
|
152
|
+
|
|
66
153
|
## Providers
|
|
67
154
|
|
|
68
|
-
| Provider | Road | Dark | Satellite | Address search |
|
|
69
|
-
| --- | --- | --- | --- | --- |
|
|
70
|
-
| `azureMaps({ key })` or `({ token, clientId })` | yes | yes | yes | yes, as people type |
|
|
71
|
-
| `googleMaps({ key, region, logo })` (Map Tiles API) | yes | no | yes |
|
|
72
|
-
| `mapbox({ token })` | yes | yes | yes | yes, as people type |
|
|
73
|
-
| `tiles({ url, credit })` | the app's own map images | | | the app's own |
|
|
74
|
-
| `openStreetMap()` | yes, **for demos only** | no | no | Photon, as people type, nearest first (or `{ search: 'nominatim' }`, on Enter) |
|
|
155
|
+
| Provider | Road | Dark | Satellite | Address search | Routes |
|
|
156
|
+
| --- | --- | --- | --- | --- | --- |
|
|
157
|
+
| `azureMaps({ key })` or `({ token, clientId })` | yes | yes | yes | yes, as people type | car, foot |
|
|
158
|
+
| `googleMaps({ key, region, logo })` (Map Tiles API) | yes | no | yes | Places API, as people type | car, bike, foot (Routes API) |
|
|
159
|
+
| `mapbox({ token })` | yes | yes | yes | yes, as people type | car (traffic), bike, foot |
|
|
160
|
+
| `tiles({ url, credit, route })` | the app's own map images | | | the app's own | the app's own |
|
|
161
|
+
| `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`) |
|
|
75
162
|
|
|
76
163
|
Keys never live in Fieldia: pass one restricted to your sites, or a function
|
|
77
164
|
fetching a short-lived token from your server. Each provider's credits are shown
|
|
@@ -94,6 +181,12 @@ search with any provider.
|
|
|
94
181
|
## In the designer
|
|
95
182
|
|
|
96
183
|
`mapKinds({ locale })` gives the designer Place and Area for its toolbox, with
|
|
97
|
-
their settings
|
|
184
|
+
their settings (a place's address search, "My location", the field its address
|
|
185
|
+
goes into, the map's height; an area's shapes); pass the map widgets to the
|
|
186
|
+
designer and its editors too. A list page's panel has its Map: where each
|
|
187
|
+
record is, its pins, its card, and how the list opens. Give the screen editor
|
|
188
|
+
`listViews` and `maps` (and `sampleCentre`, where its made-up records and
|
|
189
|
+
places are) and Try it shows the maps; with `maps` it offers a Map among its
|
|
190
|
+
blocks, whose panel sets its layers and the routes between them.
|
|
98
191
|
|
|
99
192
|
MIT. Leaflet is BSD-2-Clause; its stylesheet is included with its licence.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fieldia/map",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Fieldia's maps: a place and an area as fields, on any map provider. Leaflet, loaded only where a map is shown.",
|
|
3
|
+
"version": "0.16.0",
|
|
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",
|
|
7
7
|
"type": "commonjs",
|
|
@@ -21,8 +21,9 @@
|
|
|
21
21
|
"./package.json": "./package.json"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@fieldia/core": "0.
|
|
25
|
-
"@fieldia/
|
|
24
|
+
"@fieldia/core": "0.16.0",
|
|
25
|
+
"@fieldia/viewer": "0.16.0",
|
|
26
|
+
"@fieldia/widgets": "0.16.0",
|
|
26
27
|
"leaflet": "^1.9.4",
|
|
27
28
|
"tslib": "^2.8.1"
|
|
28
29
|
},
|
package/src/index.d.mts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export { mapWidgets } from './lib/widgets.mjs';
|
|
2
|
+
export { mapListViews } from './lib/list-view.mjs';
|
|
3
|
+
export { mapParts } from './lib/form-map.mjs';
|
|
4
|
+
export { MAP_ICONS } from './lib/map-icons.mjs';
|
|
5
|
+
export type { MapRecord, PinDrawer } from './lib/pins.mjs';
|
|
2
6
|
export { mapKinds, type MapKind, type MapKindContext } from './lib/kinds.mjs';
|
|
3
7
|
export type { MapSettings } from './lib/settings.mjs';
|
|
4
|
-
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 ReverseSearch, type SearchRequest, type TileSpec, type TilesOptions, } from './lib/providers.mjs';
|
|
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 ReverseSearch, type RouteFinder, type RouteFound, type RouteRequest, type TravelMode, type SearchRequest, type TileSpec, type TilesOptions, } from './lib/providers.mjs';
|
|
5
9
|
export { readArea, readPoint, writeArea, writePoint, metresBetween, type Area, type AreaFeature, type LatLng, type PointGeometry, type Shape } from './lib/geo.mjs';
|
|
6
10
|
export { MAP_LABELS, type MapLabels } from './lib/labels.mjs';
|
package/src/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export { mapWidgets } from './lib/widgets';
|
|
2
|
+
export { mapListViews } from './lib/list-view';
|
|
3
|
+
export { mapParts } from './lib/form-map';
|
|
4
|
+
export { MAP_ICONS } from './lib/map-icons';
|
|
5
|
+
export type { MapRecord, PinDrawer } from './lib/pins';
|
|
2
6
|
export { mapKinds, type MapKind, type MapKindContext } from './lib/kinds';
|
|
3
7
|
export type { MapSettings } from './lib/settings';
|
|
4
|
-
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 ReverseSearch, type SearchRequest, type TileSpec, type TilesOptions, } from './lib/providers';
|
|
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 ReverseSearch, type RouteFinder, type RouteFound, type RouteRequest, type TravelMode, type SearchRequest, type TileSpec, type TilesOptions, } from './lib/providers';
|
|
5
9
|
export { readArea, readPoint, writeArea, writePoint, metresBetween, type Area, type AreaFeature, type LatLng, type PointGeometry, type Shape } from './lib/geo';
|
|
6
10
|
export { MAP_LABELS, type MapLabels } from './lib/labels';
|
package/src/index.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
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.mapWidgets = void 0;
|
|
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;
|
|
4
4
|
var widgets_1 = require("./lib/widgets");
|
|
5
5
|
Object.defineProperty(exports, "mapWidgets", { enumerable: true, get: function () { return widgets_1.mapWidgets; } });
|
|
6
|
+
var list_view_1 = require("./lib/list-view");
|
|
7
|
+
Object.defineProperty(exports, "mapListViews", { enumerable: true, get: function () { return list_view_1.mapListViews; } });
|
|
8
|
+
var form_map_1 = require("./lib/form-map");
|
|
9
|
+
Object.defineProperty(exports, "mapParts", { enumerable: true, get: function () { return form_map_1.mapParts; } });
|
|
10
|
+
var map_icons_1 = require("./lib/map-icons");
|
|
11
|
+
Object.defineProperty(exports, "MAP_ICONS", { enumerable: true, get: function () { return map_icons_1.MAP_ICONS; } });
|
|
6
12
|
var kinds_1 = require("./lib/kinds");
|
|
7
13
|
Object.defineProperty(exports, "mapKinds", { enumerable: true, get: function () { return kinds_1.mapKinds; } });
|
|
8
14
|
var providers_1 = require("./lib/providers");
|
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,qCAA0E;AAAjE,iGAAA,QAAQ,OAAA;AAEjB,
|
|
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,6CAwByB;AAvBvB,sGAAA,SAAS,OAAA;AACT,uGAAA,UAAU,OAAA;AACV,mGAAA,MAAM,OAAA;AACN,0GAAA,aAAa,OAAA;AACb,kGAAA,KAAK,OAAA;AAoBP,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"}
|
package/src/index.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { mapWidgets } from './lib/widgets.mjs';
|
|
2
|
+
export { mapListViews } from './lib/list-view.mjs';
|
|
3
|
+
export { mapParts } from './lib/form-map.mjs';
|
|
4
|
+
export { MAP_ICONS } from './lib/map-icons.mjs';
|
|
2
5
|
export { mapKinds } from './lib/kinds.mjs';
|
|
3
6
|
export { azureMaps, googleMaps, mapbox, openStreetMap, tiles, } from './lib/providers.mjs';
|
|
4
7
|
export { readArea, readPoint, writeArea, writePoint, metresBetween } from './lib/geo.mjs';
|
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,QAAQ,EAAqC,MAAM,aAAa,CAAC;AAE1E,OAAO,EACL,SAAS,EACT,UAAU,EACV,MAAM,EACN,aAAa,EACb,KAAK,
|
|
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,GAmBN,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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asking a provider over the network: its answer as JSON, or its refusal in
|
|
3
|
+
* its own words, and a path read through an answer whose shape may vary.
|
|
4
|
+
* Kept apart, as the providers and their routes (loaded later) both use it.
|
|
5
|
+
*/
|
|
6
|
+
export type Fetch = typeof globalThis.fetch;
|
|
7
|
+
/**
|
|
8
|
+
* A provider's answer, or its refusal in its own words: "Places API (New) has
|
|
9
|
+
* not been used in project … or it is disabled" says what to do; a bare 403
|
|
10
|
+
* does not.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getJson(fetchWith: Fetch, url: string, init?: RequestInit): Promise<unknown>;
|
|
13
|
+
export type Json = {
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
};
|
|
16
|
+
export declare const isObject: (value: unknown) => value is Json;
|
|
17
|
+
export declare const pathOf: (value: unknown, ...path: string[]) => unknown;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asking a provider over the network: its answer as JSON, or its refusal in
|
|
3
|
+
* its own words, and a path read through an answer whose shape may vary.
|
|
4
|
+
* Kept apart, as the providers and their routes (loaded later) both use it.
|
|
5
|
+
*/
|
|
6
|
+
export type Fetch = typeof globalThis.fetch;
|
|
7
|
+
/**
|
|
8
|
+
* A provider's answer, or its refusal in its own words: "Places API (New) has
|
|
9
|
+
* not been used in project … or it is disabled" says what to do; a bare 403
|
|
10
|
+
* does not.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getJson(fetchWith: Fetch, url: string, init?: RequestInit): Promise<unknown>;
|
|
13
|
+
export type Json = {
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
};
|
|
16
|
+
export declare const isObject: (value: unknown) => value is Json;
|
|
17
|
+
export declare const pathOf: (value: unknown, ...path: string[]) => unknown;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Asking a provider over the network: its answer as JSON, or its refusal in
|
|
4
|
+
* its own words, and a path read through an answer whose shape may vary.
|
|
5
|
+
* Kept apart, as the providers and their routes (loaded later) both use it.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.pathOf = exports.isObject = void 0;
|
|
9
|
+
exports.getJson = getJson;
|
|
10
|
+
/**
|
|
11
|
+
* A provider's answer, or its refusal in its own words: "Places API (New) has
|
|
12
|
+
* not been used in project … or it is disabled" says what to do; a bare 403
|
|
13
|
+
* does not.
|
|
14
|
+
*/
|
|
15
|
+
async function getJson(fetchWith, url, init) {
|
|
16
|
+
const response = await fetchWith(url, init);
|
|
17
|
+
if (response.ok)
|
|
18
|
+
return response.json();
|
|
19
|
+
const body = await response.json().catch(() => null);
|
|
20
|
+
const said = (0, exports.pathOf)(body, 'error', 'message') ?? (0, exports.pathOf)(body, 'error_message') ?? (0, exports.pathOf)(body, 'message');
|
|
21
|
+
throw new Error(`${url.split('?')[0]} answered ${response.status}${typeof said === 'string' && said ? `: ${said}` : ''}`);
|
|
22
|
+
}
|
|
23
|
+
const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
24
|
+
exports.isObject = isObject;
|
|
25
|
+
const pathOf = (value, ...path) => path.reduce((at, key) => ((0, exports.isObject)(at) ? at[key] : undefined), value);
|
|
26
|
+
exports.pathOf = pathOf;
|
|
27
|
+
//# sourceMappingURL=answers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"answers.js","sourceRoot":"","sources":["../../../../../libs/map/src/lib/answers.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AASH,0BAMC;AAXD;;;;GAIG;AACI,KAAK,UAAU,OAAO,CAAC,SAAgB,EAAE,GAAW,EAAE,IAAkB;IAC7E,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC5C,IAAI,QAAQ,CAAC,EAAE;QAAE,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;IACxC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACrD,MAAM,IAAI,GAAG,IAAA,cAAM,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,IAAI,IAAA,cAAM,EAAC,IAAI,EAAE,eAAe,CAAC,IAAI,IAAA,cAAM,EAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC1G,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,QAAQ,CAAC,MAAM,GAAG,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC5H,CAAC;AAGM,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAiB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAAnH,QAAA,QAAQ,YAA2G;AACzH,MAAM,MAAM,GAAG,CAAC,KAAc,EAAE,GAAG,IAAc,EAAW,EAAE,CAAC,IAAI,CAAC,MAAM,CAAU,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,IAAA,gBAAQ,EAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,CAAC;AAAxI,QAAA,MAAM,UAAkI"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asking a provider over the network: its answer as JSON, or its refusal in
|
|
3
|
+
* its own words, and a path read through an answer whose shape may vary.
|
|
4
|
+
* Kept apart, as the providers and their routes (loaded later) both use it.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A provider's answer, or its refusal in its own words: "Places API (New) has
|
|
8
|
+
* not been used in project … or it is disabled" says what to do; a bare 403
|
|
9
|
+
* does not.
|
|
10
|
+
*/
|
|
11
|
+
export async function getJson(fetchWith, url, init) {
|
|
12
|
+
const response = await fetchWith(url, init);
|
|
13
|
+
if (response.ok)
|
|
14
|
+
return response.json();
|
|
15
|
+
const body = await response.json().catch(() => null);
|
|
16
|
+
const said = pathOf(body, 'error', 'message') ?? pathOf(body, 'error_message') ?? pathOf(body, 'message');
|
|
17
|
+
throw new Error(`${url.split('?')[0]} answered ${response.status}${typeof said === 'string' && said ? `: ${said}` : ''}`);
|
|
18
|
+
}
|
|
19
|
+
export const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
20
|
+
export const pathOf = (value, ...path) => path.reduce((at, key) => (isObject(at) ? at[key] : undefined), value);
|
|
21
|
+
//# sourceMappingURL=answers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"answers.mjs","sourceRoot":"","sources":["../../../../../libs/map/src/lib/answers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,SAAgB,EAAE,GAAW,EAAE,IAAkB;IAC7E,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC5C,IAAI,QAAQ,CAAC,EAAE;QAAE,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;IACxC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACrD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,eAAe,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC1G,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,QAAQ,CAAC,MAAM,GAAG,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC5H,CAAC;AAGD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAiB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAChI,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAc,EAAE,GAAG,IAAc,EAAW,EAAE,CAAC,IAAI,CAAC,MAAM,CAAU,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,CAAC"}
|