@fieldia/map 0.0.0-stage → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +98 -2
  3. package/package.json +37 -3
  4. package/src/index.d.mts +6 -0
  5. package/src/index.d.ts +6 -0
  6. package/src/index.js +22 -0
  7. package/src/index.js.map +1 -0
  8. package/src/index.mjs +6 -0
  9. package/src/index.mjs.map +1 -0
  10. package/src/lib/area.d.mts +3 -0
  11. package/src/lib/area.d.ts +3 -0
  12. package/src/lib/area.js +591 -0
  13. package/src/lib/area.js.map +1 -0
  14. package/src/lib/area.mjs +588 -0
  15. package/src/lib/area.mjs.map +1 -0
  16. package/src/lib/geo.d.mts +72 -0
  17. package/src/lib/geo.d.ts +72 -0
  18. package/src/lib/geo.js +149 -0
  19. package/src/lib/geo.js.map +1 -0
  20. package/src/lib/geo.mjs +134 -0
  21. package/src/lib/geo.mjs.map +1 -0
  22. package/src/lib/kinds.d.mts +35 -0
  23. package/src/lib/kinds.d.ts +35 -0
  24. package/src/lib/kinds.js +127 -0
  25. package/src/lib/kinds.js.map +1 -0
  26. package/src/lib/kinds.mjs +124 -0
  27. package/src/lib/kinds.mjs.map +1 -0
  28. package/src/lib/labels.d.mts +62 -0
  29. package/src/lib/labels.d.ts +62 -0
  30. package/src/lib/labels.js +226 -0
  31. package/src/lib/labels.js.map +1 -0
  32. package/src/lib/labels.mjs +221 -0
  33. package/src/lib/labels.mjs.map +1 -0
  34. package/src/lib/leaflet-css.d.mts +2 -0
  35. package/src/lib/leaflet-css.d.ts +2 -0
  36. package/src/lib/leaflet-css.js +34 -0
  37. package/src/lib/leaflet-css.js.map +1 -0
  38. package/src/lib/leaflet-css.mjs +31 -0
  39. package/src/lib/leaflet-css.mjs.map +1 -0
  40. package/src/lib/leaflet.d.mts +15 -0
  41. package/src/lib/leaflet.d.ts +15 -0
  42. package/src/lib/leaflet.js +76 -0
  43. package/src/lib/leaflet.js.map +1 -0
  44. package/src/lib/leaflet.mjs +72 -0
  45. package/src/lib/leaflet.mjs.map +1 -0
  46. package/src/lib/map-core.d.mts +49 -0
  47. package/src/lib/map-core.d.ts +49 -0
  48. package/src/lib/map-core.js +312 -0
  49. package/src/lib/map-core.js.map +1 -0
  50. package/src/lib/map-core.mjs +308 -0
  51. package/src/lib/map-core.mjs.map +1 -0
  52. package/src/lib/place.d.mts +3 -0
  53. package/src/lib/place.d.ts +3 -0
  54. package/src/lib/place.js +363 -0
  55. package/src/lib/place.js.map +1 -0
  56. package/src/lib/place.mjs +360 -0
  57. package/src/lib/place.mjs.map +1 -0
  58. package/src/lib/providers.d.mts +152 -0
  59. package/src/lib/providers.d.ts +152 -0
  60. package/src/lib/providers.js +408 -0
  61. package/src/lib/providers.js.map +1 -0
  62. package/src/lib/providers.mjs +401 -0
  63. package/src/lib/providers.mjs.map +1 -0
  64. package/src/lib/search-box.d.mts +30 -0
  65. package/src/lib/search-box.d.ts +30 -0
  66. package/src/lib/search-box.js +155 -0
  67. package/src/lib/search-box.js.map +1 -0
  68. package/src/lib/search-box.mjs +152 -0
  69. package/src/lib/search-box.mjs.map +1 -0
  70. package/src/lib/settings.d.mts +19 -0
  71. package/src/lib/settings.d.ts +19 -0
  72. package/src/lib/settings.js +3 -0
  73. package/src/lib/settings.js.map +1 -0
  74. package/src/lib/settings.mjs +2 -0
  75. package/src/lib/settings.mjs.map +1 -0
  76. package/src/lib/styles.d.mts +11 -0
  77. package/src/lib/styles.d.ts +11 -0
  78. package/src/lib/styles.js +130 -0
  79. package/src/lib/styles.js.map +1 -0
  80. package/src/lib/styles.mjs +125 -0
  81. package/src/lib/styles.mjs.map +1 -0
  82. package/src/lib/widgets.d.mts +14 -0
  83. package/src/lib/widgets.d.ts +14 -0
  84. package/src/lib/widgets.js +21 -0
  85. package/src/lib/widgets.js.map +1 -0
  86. package/src/lib/widgets.mjs +18 -0
  87. package/src/lib/widgets.mjs.map +1 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 fieldia-dev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,99 @@
1
- # Temporary Holding Version
1
+ # @fieldia/map
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [Fieldia](https://fieldia.dev)'s maps: a **place** and an **area** as fields of a
4
+ form, on the map provider you choose. Built on [Leaflet](https://leafletjs.com),
5
+ loaded only when a map is shown.
6
+
7
+ ```sh
8
+ npm install @fieldia/map
9
+ ```
10
+
11
+ ```ts
12
+ import { mountViewer } from '@fieldia/viewer';
13
+ import { mapWidgets, azureMaps } from '@fieldia/map';
14
+
15
+ mountViewer(host, {
16
+ page,
17
+ dataSource,
18
+ widgets: mapWidgets({
19
+ provider: azureMaps({ token: () => fetch('/maps/token').then((r) => r.text()) }),
20
+ center: { lat: 30.0444, lng: 31.2357 },
21
+ }),
22
+ });
23
+ ```
24
+
25
+ ## Place
26
+
27
+ A point on a form: a press on the map, a dragged pin, an address found, typed
28
+ coordinates, or "My location". On a `json` field it is kept as a GeoJSON Point;
29
+ on a `float` field it keeps the latitude, with `longitudeField` naming the field
30
+ for the longitude.
31
+
32
+ ```json
33
+ { "type": "field", "id": "deliver_to", "field": "deliver_to", "widget": "place",
34
+ "options": { "addressField": "street", "zoom": 17 } }
35
+ ```
36
+
37
+ Options: `longitudeField`, `addressField` (filled from the address found, or
38
+ named from the point where the provider can, never over what a person typed),
39
+ `myLocation` and `search` (on unless `false`), `zoom`, `height`.
40
+
41
+ ## Area
42
+
43
+ A polygon, a box or a circle, kept in a `json` field as a GeoJSON Feature whose
44
+ `properties.shape` says how it was drawn (a circle is its centre and
45
+ `properties.radius` in metres). Its points, corners and edge drag to change it,
46
+ the whole area drags to move it, and a point between two adds one.
47
+
48
+ ```json
49
+ { "type": "field", "id": "zone", "field": "zone", "widget": "area",
50
+ "options": { "shapes": ["polygon", "box"], "areas": [{ "label": "Downtown", "value": { "type": "Polygon", "coordinates": [[[31.235, 30.04], [31.25, 30.04], [31.25, 30.055], [31.235, 30.04]]] } }] } }
51
+ ```
52
+
53
+ Options: `shapes` (any of polygon, box, circle), `areas` (named areas to choose
54
+ instead of drawing), `height`.
55
+
56
+ ## Without a mouse
57
+
58
+ Tab reaches the map, which shows a cross at its centre: the arrow keys move the
59
+ map, plus and minus zoom. On a place, Enter puts the place at the cross and the
60
+ arrow keys move the pin. On an area, Space puts a point at the cross, Enter
61
+ finishes, Backspace takes a point back, Escape stops; a grip moves with the
62
+ arrow keys and leaves with Delete. A scroll passes over a map to the page
63
+ unless Ctrl (⌘) is held, and on a phone one finger scrolls the page while two
64
+ move the map.
65
+
66
+ ## Providers
67
+
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 | the app's own (`search`) |
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) |
75
+
76
+ Keys never live in Fieldia: pass one restricted to your sites, or a function
77
+ fetching a short-lived token from your server. Each provider's credits are shown
78
+ in the map's corner, and its mark where its terms ask. Read your provider's
79
+ terms on keeping search results: a place field keeps what it finds (Mapbox's
80
+ permanent geocoding is asked for by default). OpenStreetMap's public map images,
81
+ Photon's public server and Nominatim are for trying things out: their policies
82
+ treat an app in use as heavy use. Photon can run on your own server
83
+ (`openStreetMap({ photonUrl })`).
84
+
85
+ Suggestions come as people type where the provider allows it, nearest where the
86
+ map is looking first, each on two lines (the place, then where it is); Enter
87
+ takes the first. "My location" says how sure it is: a rough location (a
88
+ desktop's, placed by its network) shows the circle it may be anywhere in, says
89
+ how wide, and names no address from it.
90
+
91
+ Pass your own `search` (and `reverse`) to `mapWidgets` to use your own address
92
+ search with any provider.
93
+
94
+ ## In the designer
95
+
96
+ `mapKinds({ locale })` gives the designer Place and Area for its toolbox, with
97
+ their settings; pass the map widgets to the designer and its editors too.
98
+
99
+ MIT. Leaflet is BSD-2-Clause; its stylesheet is included with its licence.
package/package.json CHANGED
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "name": "@fieldia/map",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.14.1",
4
+ "description": "Fieldia's maps: a place and an area as fields, on any map provider. Leaflet, loaded only where a map is shown.",
5
+ "license": "MIT",
6
+ "homepage": "https://fieldia.dev",
7
+ "type": "commonjs",
8
+ "main": "./src/index.js",
9
+ "module": "./src/index.mjs",
10
+ "types": "./src/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": {
14
+ "import": "./src/index.d.mts",
15
+ "require": "./src/index.d.ts"
16
+ },
17
+ "import": "./src/index.mjs",
18
+ "require": "./src/index.js",
19
+ "default": "./src/index.js"
20
+ },
21
+ "./package.json": "./package.json"
22
+ },
23
+ "dependencies": {
24
+ "@fieldia/core": "0.14.1",
25
+ "@fieldia/widgets": "0.14.1",
26
+ "leaflet": "^1.9.4",
27
+ "tslib": "^2.8.1"
28
+ },
29
+ "sideEffects": false,
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/fieldia-dev/fieldia",
33
+ "directory": "libs/map"
34
+ },
35
+ "files": [
36
+ "src",
37
+ "README.md",
38
+ "LICENSE"
39
+ ]
6
40
  }
@@ -0,0 +1,6 @@
1
+ export { mapWidgets } from './lib/widgets.mjs';
2
+ export { mapKinds, type MapKind, type MapKindContext } from './lib/kinds.mjs';
3
+ 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';
5
+ export { readArea, readPoint, writeArea, writePoint, metresBetween, type Area, type AreaFeature, type LatLng, type PointGeometry, type Shape } from './lib/geo.mjs';
6
+ export { MAP_LABELS, type MapLabels } from './lib/labels.mjs';
package/src/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export { mapWidgets } from './lib/widgets';
2
+ export { mapKinds, type MapKind, type MapKindContext } from './lib/kinds';
3
+ 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';
5
+ export { readArea, readPoint, writeArea, writePoint, metresBetween, type Area, type AreaFeature, type LatLng, type PointGeometry, type Shape } from './lib/geo';
6
+ export { MAP_LABELS, type MapLabels } from './lib/labels';
package/src/index.js ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";
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;
4
+ var widgets_1 = require("./lib/widgets");
5
+ Object.defineProperty(exports, "mapWidgets", { enumerable: true, get: function () { return widgets_1.mapWidgets; } });
6
+ var kinds_1 = require("./lib/kinds");
7
+ Object.defineProperty(exports, "mapKinds", { enumerable: true, get: function () { return kinds_1.mapKinds; } });
8
+ var providers_1 = require("./lib/providers");
9
+ Object.defineProperty(exports, "azureMaps", { enumerable: true, get: function () { return providers_1.azureMaps; } });
10
+ Object.defineProperty(exports, "googleMaps", { enumerable: true, get: function () { return providers_1.googleMaps; } });
11
+ Object.defineProperty(exports, "mapbox", { enumerable: true, get: function () { return providers_1.mapbox; } });
12
+ Object.defineProperty(exports, "openStreetMap", { enumerable: true, get: function () { return providers_1.openStreetMap; } });
13
+ Object.defineProperty(exports, "tiles", { enumerable: true, get: function () { return providers_1.tiles; } });
14
+ var geo_1 = require("./lib/geo");
15
+ Object.defineProperty(exports, "readArea", { enumerable: true, get: function () { return geo_1.readArea; } });
16
+ Object.defineProperty(exports, "readPoint", { enumerable: true, get: function () { return geo_1.readPoint; } });
17
+ Object.defineProperty(exports, "writeArea", { enumerable: true, get: function () { return geo_1.writeArea; } });
18
+ Object.defineProperty(exports, "writePoint", { enumerable: true, get: function () { return geo_1.writePoint; } });
19
+ Object.defineProperty(exports, "metresBetween", { enumerable: true, get: function () { return geo_1.metresBetween; } });
20
+ var labels_1 = require("./lib/labels");
21
+ Object.defineProperty(exports, "MAP_LABELS", { enumerable: true, get: function () { return labels_1.MAP_LABELS; } });
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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,6CAoByB;AAnBvB,sGAAA,SAAS,OAAA;AACT,uGAAA,UAAU,OAAA;AACV,mGAAA,MAAM,OAAA;AACN,0GAAA,aAAa,OAAA;AACb,kGAAA,KAAK,OAAA;AAgBP,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 ADDED
@@ -0,0 +1,6 @@
1
+ export { mapWidgets } from './lib/widgets.mjs';
2
+ export { mapKinds } from './lib/kinds.mjs';
3
+ export { azureMaps, googleMaps, mapbox, openStreetMap, tiles, } from './lib/providers.mjs';
4
+ export { readArea, readPoint, writeArea, writePoint, metresBetween } from './lib/geo.mjs';
5
+ export { MAP_LABELS } from './lib/labels.mjs';
6
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +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,GAeN,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,3 @@
1
+ import type { WidgetFactory } from '@fieldia/widgets';
2
+ import type { MapSettings } from './settings.mjs';
3
+ export declare function areaWidget(settings: MapSettings): WidgetFactory;
@@ -0,0 +1,3 @@
1
+ import type { WidgetFactory } from '@fieldia/widgets';
2
+ import type { MapSettings } from './settings';
3
+ export declare function areaWidget(settings: MapSettings): WidgetFactory;