@florasync/leaflet-geokit 0.9.0 → 0.10.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/ARCHITECTURE.md +195 -0
- package/CHANGELOG.md +5 -0
- package/README.md +7 -1
- package/custom-toolbar.html +165 -0
- package/dist/django/index.js +734 -734
- package/dist/django/index.js.map +1 -1
- package/dist/leaflet-geokit.es.js +1704 -1704
- package/dist/leaflet-geokit.es.js.map +1 -1
- package/dist/leaflet-geokit.external.es.js +1501 -1496
- package/dist/leaflet-geokit.external.es.js.map +1 -1
- package/dist/leaflet-geokit.umd.js +11 -14
- package/dist/leaflet-geokit.umd.js.map +1 -1
- package/dist/preact/{index-DCKj0r6a.js → index-Z22Un5Tg.js} +474 -469
- package/dist/preact/index-Z22Un5Tg.js.map +1 -0
- package/dist/preact/index.js +1 -1
- package/dist/preact-bundled/index.js +731 -731
- package/dist/preact-bundled/index.js.map +1 -1
- package/dist/react/{index-DCKj0r6a.js → index-Z22Un5Tg.js} +474 -469
- package/dist/react/index-Z22Un5Tg.js.map +1 -0
- package/dist/react/index.js +1 -1
- package/dist/react-bundled/index.js +731 -731
- package/dist/react-bundled/index.js.map +1 -1
- package/dist/types/components/LeafletDrawMapElement.d.ts +6 -6
- package/dist/types/django/index.d.ts +2 -2
- package/dist/types/external.d.ts +9 -9
- package/dist/types/index.d.ts +9 -9
- package/dist/types/lib/FeatureStore.d.ts +2 -2
- package/dist/types/lib/LayerRegistry.d.ts +1 -1
- package/dist/types/lib/MapController.d.ts +8 -8
- package/dist/types/lib/layer-cake/LayerCakeManager.d.ts +2 -2
- package/dist/types/lib/layer-style-panel.d.ts +1 -1
- package/dist/types/lib/marker-icons.d.ts +1 -1
- package/dist/types/lib/providers.d.ts +1 -1
- package/dist/types/lib/snapping.d.ts +1 -1
- package/dist/types/lib/tool-buttons.d.ts +1 -1
- package/dist/types/lib/tool-capabilities.d.ts +1 -1
- package/dist/types/lib/toolbar-layout.d.ts +1 -1
- package/dist/types/preact/core.d.ts +2 -2
- package/dist/types/preact/index.d.ts +2 -2
- package/dist/types/preact-bundled/index.d.ts +3 -3
- package/dist/types/react/core.d.ts +2 -2
- package/dist/types/react/index.d.ts +2 -2
- package/dist/types/react-bundled/index.d.ts +3 -3
- package/dist/types/types/events.d.ts +1 -1
- package/dist/types/types/public.d.ts +6 -6
- package/dist/types/utils/geojson-pipeline.d.ts +1 -1
- package/dist/types/utils/geojson.d.ts +1 -1
- package/docs/api-reference.md +249 -0
- package/docs/custom-toolbar.md +168 -0
- package/docs/diagnostics.md +216 -0
- package/docs/grower-measurement.md +23 -0
- package/docs/integration-recipes.md +301 -0
- package/docs/release-verification.md +75 -0
- package/docs/shims/django.md +102 -0
- package/docs/shims/preact.md +98 -0
- package/docs/shims/react.md +98 -0
- package/docs/toolbar-layout.md +158 -0
- package/docs/toolbar-styling.md +2 -2
- package/package.json +15 -4
- package/dist/preact/index-DCKj0r6a.js.map +0 -1
- package/dist/react/index-DCKj0r6a.js.map +0 -1
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# Branded toolbars and external buttons
|
|
2
|
+
|
|
3
|
+
Start with [the complete plain HTML example](../custom-toolbar.html): run
|
|
4
|
+
`npm run dev`, then open `/custom-toolbar.html`. It uses only public element
|
|
5
|
+
properties, events, CSS parts and tokens; no Leaflet toolbar DOM surgery. The
|
|
6
|
+
example imports `/src/index.ts` for Vite development. In a consumer bundler replace
|
|
7
|
+
that import with `@florasync/leaflet-geokit`; do not deploy a `/src` URL. For direct
|
|
8
|
+
browser modules use the version-pinned [Django entrypoint](shims/django.md).
|
|
9
|
+
|
|
10
|
+
## Choose the customization layer
|
|
11
|
+
|
|
12
|
+
| API | Use |
|
|
13
|
+
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
|
14
|
+
| `toolButtonConfig` | Labels, icons, classes, popovers and visual defaults keyed by tool name. |
|
|
15
|
+
| `toolbarGroups` | Explicit tool order, placement and semantic group labels. |
|
|
16
|
+
| `className` | App-owned classes on individual buttons. Target these inside `themeCss`, not document-level descendant selectors across Shadow DOM. |
|
|
17
|
+
| `iconUrl` | An app-owned SVG/PNG URL. Resolve bundled assets with `new URL("./icon.svg", import.meta.url).href`. |
|
|
18
|
+
| `iconHtml` | Developer-owned inline SVG/HTML, allowing `currentColor`. |
|
|
19
|
+
| `renderIcon` | JS property callback returning an HTMLElement, SVGElement, string, null or undefined. Functions cannot be represented in JSON attributes. |
|
|
20
|
+
| `popover` | Point-of-action guidance with `title`, text `body`, trusted `html` or a `render` callback. |
|
|
21
|
+
| CSS custom properties / `::part` | Host theme overrides without depending on private Leaflet structure. |
|
|
22
|
+
|
|
23
|
+
See [the API reference](api-reference.md), [styling tokens/parts/slots](toolbar-styling.md),
|
|
24
|
+
[responsive zones and overflow](toolbar-layout.md), and [keyboard accessibility](accessibility.md).
|
|
25
|
+
Property configuration overrides JSON attributes. `undefined` restores attribute
|
|
26
|
+
fallback; `null` clears programmatic configuration. Set configuration before
|
|
27
|
+
mount when possible, or assign through public setters after upgrade.
|
|
28
|
+
|
|
29
|
+
## Minimal toolbar configuration
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
map.toolButtonConfig = {
|
|
33
|
+
polygon: {
|
|
34
|
+
title: "Draw growing space",
|
|
35
|
+
ariaLabel: "Draw growing space",
|
|
36
|
+
className: "flora-primary",
|
|
37
|
+
iconUrl: "/assets/growing-space.svg",
|
|
38
|
+
popover: {
|
|
39
|
+
title: "Boundary",
|
|
40
|
+
body: "Click corners, then the first point to finish.",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
save: { title: "Save growing spaces", ariaLabel: "Save growing spaces" },
|
|
44
|
+
};
|
|
45
|
+
map.toolbarGroups = [
|
|
46
|
+
{
|
|
47
|
+
id: "grow",
|
|
48
|
+
tools: ["polygon", "select", "save"],
|
|
49
|
+
position: "bottomleft",
|
|
50
|
+
orientation: "horizontal",
|
|
51
|
+
offset: [12, 12],
|
|
52
|
+
hideDefaultToolbar: true,
|
|
53
|
+
ariaLabel: "Growing-space tools",
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Enable the matching tool attributes, e.g. `draw-polygon`. Placement supports
|
|
59
|
+
`topleft`, `topright`, `bottomleft`, `bottomright`. `offset` is `[x, y]` in pixels.
|
|
60
|
+
The native draw/ruler toolbar hides when **any** group has
|
|
61
|
+
`hideDefaultToolbar: true` (the default). Set it false on **every** group to keep
|
|
62
|
+
native controls. `select` cancels drawing; `save` emits `leaflet-draw:export`—it
|
|
63
|
+
is not a server write. Persist `event.detail.geoJSON` in your host application.
|
|
64
|
+
|
|
65
|
+
## Host-app CSS
|
|
66
|
+
|
|
67
|
+
```css
|
|
68
|
+
leaflet-geokit {
|
|
69
|
+
display: block;
|
|
70
|
+
width: 100%;
|
|
71
|
+
height: 65vh;
|
|
72
|
+
min-height: 320px;
|
|
73
|
+
--geokit-tool-size: 48px;
|
|
74
|
+
--geokit-tool-radius: 12px;
|
|
75
|
+
--geokit-tool-background: #edf6ee;
|
|
76
|
+
--geokit-tool-color: #183b27;
|
|
77
|
+
--geokit-tool-focus-ring: 3px solid #287d47;
|
|
78
|
+
--geokit-toolbar-background: #f4f8f2;
|
|
79
|
+
--geokit-toolbar-gap: 8px;
|
|
80
|
+
}
|
|
81
|
+
leaflet-geokit::part(toolbar-group) {
|
|
82
|
+
border: 1px solid #287d47;
|
|
83
|
+
}
|
|
84
|
+
[data-theme="dark"] leaflet-geokit {
|
|
85
|
+
--geokit-tool-background: #203d2a;
|
|
86
|
+
--geokit-tool-color: #e0f1de;
|
|
87
|
+
--geokit-toolbar-background: #15261b;
|
|
88
|
+
--geokit-tool-hover-background: #31563c;
|
|
89
|
+
--geokit-tool-focus-ring: 3px solid #9fdaaa;
|
|
90
|
+
}
|
|
91
|
+
@media (prefers-reduced-motion: reduce) {
|
|
92
|
+
leaflet-geokit::part(toolbar-button) {
|
|
93
|
+
transition: none;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
For per-tool styling, assign
|
|
99
|
+
`map.themeCss = '[data-geokit-tool="polygon"].flora-primary { --geokit-tool-radius: 50%; }'`.
|
|
100
|
+
Document-level `.flora-primary` rules cannot pierce Shadow DOM. Do not query private
|
|
101
|
+
Leaflet classes or replace internal buttons; setters may rerender groups.
|
|
102
|
+
|
|
103
|
+
## External layer-cake button
|
|
104
|
+
|
|
105
|
+
Use a native `<button type="button" disabled>Build layered zone</button>` outside
|
|
106
|
+
the map and enable `draw-layer-cake` on `<leaflet-geokit>`. Bind its disabled state to the capability snapshot rather than guessing
|
|
107
|
+
whether initialization has finished:
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
function refresh() {
|
|
111
|
+
const capability = map.getToolCapabilities().tools.layerCake;
|
|
112
|
+
button.disabled = capability.state !== "enabled";
|
|
113
|
+
button.title = capability.reason?.message ?? "Build layered zone";
|
|
114
|
+
}
|
|
115
|
+
map.addEventListener("leaflet-geokit:tool-capabilities-changed", refresh);
|
|
116
|
+
refresh();
|
|
117
|
+
button.addEventListener("click", async () => {
|
|
118
|
+
await map.activateTool("layerCake", { source: "external-layer-button" });
|
|
119
|
+
});
|
|
120
|
+
cancelButton.addEventListener("click", async () => {
|
|
121
|
+
await map.deactivateTool({ source: "external-layer-button" });
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
The event alternative dispatches **on the map element**, not an unrelated button:
|
|
126
|
+
|
|
127
|
+
```js
|
|
128
|
+
map.dispatchEvent(
|
|
129
|
+
new CustomEvent("leaflet-geokit:activate-tool", {
|
|
130
|
+
detail: { tool: "layerCake", source: "external-layer-button" },
|
|
131
|
+
}),
|
|
132
|
+
);
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Listen to `leaflet-geokit:tool-failed` for actionable failures; do not equate a
|
|
136
|
+
resolved command promise with persisted geometry. See [tool lifecycle](tool-lifecycle.md)
|
|
137
|
+
and [layer-cake session methods](layers.md). Remove listeners when your framework
|
|
138
|
+
unmounts. UI-only `configured_disabled` does not prohibit imperative activation:
|
|
139
|
+
your external button should respect `state`, not only `commandEnabled`.
|
|
140
|
+
|
|
141
|
+
## Trust boundary: SVG, HTML and URLs
|
|
142
|
+
|
|
143
|
+
`iconHtml`, string renderer results, popover HTML and `themeCss` are trusted-code
|
|
144
|
+
surfaces, not sanitizers. Never interpolate uploaded GeoJSON properties, user
|
|
145
|
+
labels, remote markup or database text into these strings. Prefer `iconUrl` for
|
|
146
|
+
reviewed static assets and DOM nodes populated via `textContent` for untrusted
|
|
147
|
+
text. If rich untrusted markup is unavoidable, sanitize in the host using a vetted
|
|
148
|
+
policy before passing it; do not rely on Shadow DOM for isolation. Keep URLs
|
|
149
|
+
allowlisted and compatible with your CSP. Never put private provider credentials
|
|
150
|
+
in browser markup, diagnostic logs or screenshots.
|
|
151
|
+
|
|
152
|
+
## Integration and screenshot checklist
|
|
153
|
+
|
|
154
|
+
- Give the host and its containing layout real width/height; test hidden-tab reveal.
|
|
155
|
+
- Check toolbar/popover z-index against host dialogs and sticky navigation.
|
|
156
|
+
- Check light/dark hover, active, disabled, icon contrast and popover readability.
|
|
157
|
+
- Keep touch targets at least 44 × 44 CSS pixels; verify tool access at mobile,
|
|
158
|
+
tablet and desktop widths, including overflow scrolling.
|
|
159
|
+
- Keep visible focus rings, accessible names, arrow-key group navigation and Escape.
|
|
160
|
+
- Honor reduced motion; never convey state through animation or color alone.
|
|
161
|
+
- Capture light/dark screenshots at all three viewport classes. Inspect actual
|
|
162
|
+
layout, not only no-error/no-clipping assertions. A cramped map can pass both.
|
|
163
|
+
- Exercise polygon completion, Save export, external layer-cake activation and Cancel.
|
|
164
|
+
- Confirm import, teardown/remount and both bundled/external modes used by the app.
|
|
165
|
+
|
|
166
|
+
The existing [irrigation harness](../irrigation-draw-mode.html) retains the larger
|
|
167
|
+
secondary-toolbar and external-panel drawing scenarios; do not replace those
|
|
168
|
+
regression checks with screenshots of an idle toolbar.
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# Diagnostics and troubleshooting
|
|
2
|
+
|
|
3
|
+
Use the public element API, not `_controller` or Leaflet handler internals.
|
|
4
|
+
[API reference](api-reference.md), [event types](../src/types/events.ts), and
|
|
5
|
+
[element implementation](../src/components/LeafletDrawMapElement.ts) define the
|
|
6
|
+
surfaces below. Diagnostics describe failures; they do not guarantee recovery,
|
|
7
|
+
transaction rollback, provider health, or successful persistence.
|
|
8
|
+
|
|
9
|
+
## Choose the right signal
|
|
10
|
+
|
|
11
|
+
| Surface | Purpose / delivery |
|
|
12
|
+
| ---------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
13
|
+
| `map.status` and `leaflet-geokit:status` | Durable detached state snapshot. Subscribe directly on the element and read an initial snapshot. |
|
|
14
|
+
| `leaflet-geokit:diagnostic` | Structured component/controller/provider warning or error. Direct element listener; not bubbling/composed. |
|
|
15
|
+
| `leaflet-draw:error` | Legacy error notification. Component/controller errors also produce a diagnostic and update status. Not bubbling/composed. |
|
|
16
|
+
| `tile-provider-error` | Built-in raster provider failure; bubbles, not composed. Also emits a warning diagnostic; does **not** use the legacy error event. |
|
|
17
|
+
| `leaflet-geokit:tool-failed` | Correlated tool command failure with a human-readable `reason`. Bubbling/composed; not a component error-code catalog. |
|
|
18
|
+
| `getToolCapabilities()` and `leaflet-geokit:tool-capabilities-changed` | Why each tool is enabled, disabled, or unavailable, plus requested/active provider. |
|
|
19
|
+
| `getProviderDiagnostics()` | Detached basemap **configuration** report; null without initialized diagnostics. Not a tile-load or key-validity check. |
|
|
20
|
+
| GeoJSON helper results / `GeoJSONValidationError.summary` | Data validation diagnostics with paths; separate from DOM diagnostic events. |
|
|
21
|
+
| Promise rejection or synchronous exception | Caller must catch it. Not every public-method exception is forwarded to the diagnostic event. |
|
|
22
|
+
|
|
23
|
+
Avoid double-reporting a legacy error and its corresponding diagnostic. Log
|
|
24
|
+
levels affect console output, not whether public diagnostic events are emitted.
|
|
25
|
+
|
|
26
|
+
## Status and diagnostic payloads
|
|
27
|
+
|
|
28
|
+
`StatusEventDetail` contains `state`, `ready`, `busy`, `featureCount`, optional
|
|
29
|
+
`lastEvent`, optional `lastError`, and `timestamp`. `lastError` contains only
|
|
30
|
+
`code`, `message`, `recoverable`, `timestamp`; it omits the raw cause but its
|
|
31
|
+
message can still contain sensitive input. A successful operation may clear it;
|
|
32
|
+
status is not an audit history. Timestamps are milliseconds since the Unix epoch.
|
|
33
|
+
|
|
34
|
+
| State | Interpretation |
|
|
35
|
+
| --------------- | ----------------------------------------------------------------------------------- |
|
|
36
|
+
| `uninitialized` | Before connection or after disconnect; not ready, not busy. |
|
|
37
|
+
| `initializing` | Connection/map initialization in progress. |
|
|
38
|
+
| `ready` | Map ready; recoverable warnings can coexist with this state. |
|
|
39
|
+
| `loading` | GeoJSON import in progress; `ready` can remain true for an already initialized map. |
|
|
40
|
+
| `error` | Nonrecoverable controller initialization failure; inspect diagnostic. |
|
|
41
|
+
|
|
42
|
+
`DiagnosticEventDetail` adds `severity: "info" | "warn" | "error"`, `state`, and
|
|
43
|
+
optional `cause` to the summary. The type permits `info`; current component
|
|
44
|
+
error forwarding uses `warn` when recoverable and `error` otherwise. Recoverable
|
|
45
|
+
means the map may remain usable, not that the requested operation succeeded.
|
|
46
|
+
The diagnostic event precedes its associated status update: use `detail.state`
|
|
47
|
+
in that callback or observe the following status event.
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
import "@florasync/leaflet-geokit";
|
|
51
|
+
|
|
52
|
+
const map = document.createElement("leaflet-geokit");
|
|
53
|
+
map.style.cssText = "width:100%;height:400px";
|
|
54
|
+
map.logLevel = "warn";
|
|
55
|
+
map.addEventListener("leaflet-geokit:diagnostic", ({ detail }) => {
|
|
56
|
+
// Deliberately omit message/cause/URLs/keys from shared telemetry.
|
|
57
|
+
console.warn({
|
|
58
|
+
code: detail.code,
|
|
59
|
+
severity: detail.severity,
|
|
60
|
+
recoverable: detail.recoverable,
|
|
61
|
+
state: detail.state,
|
|
62
|
+
timestamp: detail.timestamp,
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
map.addEventListener("leaflet-geokit:status", ({ detail }) => {
|
|
66
|
+
console.log({ state: detail.state, busy: detail.busy });
|
|
67
|
+
});
|
|
68
|
+
map.addEventListener("leaflet-geokit:tool-failed", ({ detail }) => {
|
|
69
|
+
console.warn({ tool: detail.tool, commandId: detail.commandId });
|
|
70
|
+
});
|
|
71
|
+
document.body.append(map);
|
|
72
|
+
console.log(map.status);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
For async calls, still use `try`/`catch`; for example, catch a rejection from
|
|
76
|
+
`loadGeoJSONFromUrl()` even if the diagnostic listener already updates the UI.
|
|
77
|
+
|
|
78
|
+
## Component and controller error catalog
|
|
79
|
+
|
|
80
|
+
These codes come from the element and [MapController](../src/lib/MapController.ts).
|
|
81
|
+
The public `code` type is a string, not a closed enum; tolerate unknown future
|
|
82
|
+
codes and use the code rather than matching message text.
|
|
83
|
+
|
|
84
|
+
| Code | Recoverable / severity | Trigger and recovery |
|
|
85
|
+
| ---------------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
86
|
+
| `map_init_failed` | No / error | Leaflet map initialization failed. Check host size, browser globals, runtime/plugin identity, and styling/runtime configuration. Fix prerequisites before reconnecting; preserve host data outside the element. |
|
|
87
|
+
| `controller_error` | Yes / warn by default | Generic controller operation failure. Inspect the local message/cause and reproduce the specific operation; do not assume rollback. |
|
|
88
|
+
| `invalid_marker_icon_config` | Yes / warn | Invalid marker URL or tuple/configuration. Correct URL/size/anchor fields; invalid optional values fall back individually, invalid primary URL uses default markers. |
|
|
89
|
+
| `invalid_tool_button_config` | Yes / warn | `tool-button-config` JSON parse or object-shape failure. Supply an object keyed by valid tool names; use the property for functions. |
|
|
90
|
+
| `invalid_toolbar_groups` | Yes / warn | `toolbar-groups` JSON parse or array-shape failure. Supply an array with group IDs/tool lists. |
|
|
91
|
+
| `data_fetch_failed` | Yes / warn | URL import network rejection or non-success HTTP response. Check URL trust, CORS, connectivity, authentication and response status; retry explicitly. Promise rejects. |
|
|
92
|
+
| `data_parse_failed` | Yes / warn | URL/text import is not parseable JSON. Check response body/content type or uploaded text; parsing JSON alone does not validate GeoJSON. Promise rejects. |
|
|
93
|
+
| `data_load_failed` | Yes / warn | Replacement import failed after parsing/ingest. Inspect validation/render cause; use preflight validation before replacing data. Promise rejects. |
|
|
94
|
+
| `data_add_failed` | Yes / warn | Additive import failed. With validated imports, inspect duplicate IDs as well as geometry. Promise rejects. |
|
|
95
|
+
|
|
96
|
+
Invalid toolbar JSON falls back to no custom configuration/groups; this is not a
|
|
97
|
+
schema validation service for every nested renderer setting. Other renderer or
|
|
98
|
+
host-hook problems may be logged or thrown rather than assigned one of these
|
|
99
|
+
codes. For safe data replacement, `importGeoJSON(fc, { validate: true })` validates
|
|
100
|
+
after the mutable ingest hook and before clearing data. This protects validation
|
|
101
|
+
failures, not arbitrary rendering failures. URL/text convenience methods currently
|
|
102
|
+
forward only behavior/fit options; validate through the pipeline helpers and then
|
|
103
|
+
call `importGeoJSON` explicitly.
|
|
104
|
+
|
|
105
|
+
## Raster provider error catalog
|
|
106
|
+
|
|
107
|
+
`TileProviderErrorDetail` contains `code`, `message`, `provider`, `timestamp`.
|
|
108
|
+
These errors also emit a recoverable warning diagnostic and attempt OSM raster
|
|
109
|
+
fallback. The requested provider remains visible in tool capabilities, even
|
|
110
|
+
when the active basemap is OSM. Local geometry tools do not require HERE.
|
|
111
|
+
Fallback attempts are not proof that the public OSM service is reachable.
|
|
112
|
+
|
|
113
|
+
| Code | Meaning / next check |
|
|
114
|
+
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
115
|
+
| `missing_api_key` | HERE requested without a nonempty key. Choose OSM/custom tiles or configure an approved provider integration. |
|
|
116
|
+
| `unknown_provider` | Unsupported named provider. Use `osm`/`here`; custom URLs belong in `tile-url` with `tileProvider` cleared. |
|
|
117
|
+
| `permission_denied` | HERE tile error text indicates permission/forbidden/403/unauthorized/access denial. Inspect permitted API/product, project permissions, origin/referrer restrictions and style access. |
|
|
118
|
+
| `invalid_api_key` | Remaining HERE tile errors are classified this way. This is a heuristic, **not proof the key is invalid**; inspect Network/CORS/connectivity and provider response too. |
|
|
119
|
+
| `tile_load_failed` | Generic custom/OSM tile failure, tile setup exception, or other configuration validation failure. Inspect the actual network request and tile template/placeholders. |
|
|
120
|
+
|
|
121
|
+
`tile-provider-changed` means a provider layer was installed, not that all tiles
|
|
122
|
+
loaded successfully. An injected basemap adapter has different failure semantics:
|
|
123
|
+
synchronous mount failures preserve the previous basemap; asynchronous renderer
|
|
124
|
+
errors belong to the bridge. See [provider contracts and limits](providers.md).
|
|
125
|
+
|
|
126
|
+
Provider configuration diagnostics contain only `kind`, `attribution`,
|
|
127
|
+
`attributionRequired`, `offline`, `apiKey`, `drawing`, and `scope`.
|
|
128
|
+
`scope: "configuration"` is deliberate; `apiKey` describes credential requirements,
|
|
129
|
+
not a key value or validation result. `offline: "host-managed"` is a declaration,
|
|
130
|
+
not proof of offline assets/cache. See the exhaustive
|
|
131
|
+
[provider capability table](providers.md#capability-diagnostics).
|
|
132
|
+
|
|
133
|
+
## Tool requirement diagnostics
|
|
134
|
+
|
|
135
|
+
Tool reasons are separate from component error codes. Use
|
|
136
|
+
`getToolCapabilities().tools[tool].reason`, not the text of `tool-failed.reason`,
|
|
137
|
+
for stable prerequisite codes. The complete codes are `not_ready`, `read_only`,
|
|
138
|
+
`missing_attribute`, `unavailable_plugin`, `empty_selection`, `no_editable_layers`,
|
|
139
|
+
`missing_provider`, `missing_api_key`, `runtime_error`, `configured_disabled`.
|
|
140
|
+
Their exhaustive recovery/precedence table is in
|
|
141
|
+
[tool capabilities](tool-capabilities.md#requirements-and-recovery).
|
|
142
|
+
|
|
143
|
+
Important distinctions:
|
|
144
|
+
|
|
145
|
+
- Removing read-only means removing the attribute or setting `readOnly = false`,
|
|
146
|
+
not writing `read-only="false"` (including when a reason says `read-only=false`).
|
|
147
|
+
- Delete needs both `delete-features` and `edit-features`. Move/edit/delete need
|
|
148
|
+
actual editable layers, not just a stored feature count.
|
|
149
|
+
- Host `disabled` controls buttons, not imperative activation. `commandEnabled`
|
|
150
|
+
also allows explicit runtime-failure retries; do not equate it with `state`.
|
|
151
|
+
- Selection prerequisites are opt-in. Supply IDs with `setToolSelection()`;
|
|
152
|
+
GeoKit does not invent a global selection UI.
|
|
153
|
+
- An activation result of `true` is not completion. Observe correlated
|
|
154
|
+
`tool-completed`/`tool-cancelled`/`tool-failed` events as described in
|
|
155
|
+
[tool lifecycle](tool-lifecycle.md).
|
|
156
|
+
|
|
157
|
+
## GeoJSON and geometry diagnostics
|
|
158
|
+
|
|
159
|
+
The [pipeline contract](geojson-pipelines.md#diagnostics-and-limits) describes
|
|
160
|
+
validation limits and source metadata behavior. Helper diagnostics use
|
|
161
|
+
`severity: "error" | "warning" | "info"` (note **warning**, not DOM diagnostic
|
|
162
|
+
**warn**), `code`, `path`, and `message`. They are returned in results or carried
|
|
163
|
+
by `GeoJSONValidationError.summary`, not automatically dispatched as DOM events.
|
|
164
|
+
|
|
165
|
+
`invalid-json` identifies text parsing failure; `crs-mismatch` warns about CRS or
|
|
166
|
+
coordinate ranges without reprojecting; `multi-expansion` is information about
|
|
167
|
+
editing expansion; `metadata-conflict` requires reconciling sibling properties
|
|
168
|
+
before safe source export. Geometry structure, positions, IDs, rings and reserved
|
|
169
|
+
provenance have additional validation diagnostics defined in
|
|
170
|
+
[geojson-pipeline.ts](../src/utils/geojson-pipeline.ts). Do not treat structural
|
|
171
|
+
validation as comprehensive topology validation or silent geometry repair.
|
|
172
|
+
|
|
173
|
+
Grower operations have their own typed result/error contract; consult
|
|
174
|
+
[grower geometry](grower-geometry.md) and [measurements](grower-measurement.md).
|
|
175
|
+
Do not confuse a helper failure result with map readiness or basemap availability.
|
|
176
|
+
|
|
177
|
+
## Troubleshooting by symptom
|
|
178
|
+
|
|
179
|
+
| Symptom | Checks / remedy |
|
|
180
|
+
| --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
181
|
+
| Blank or zero-height map | Give the host explicit dimensions; inspect its computed size. Wait for readiness and check initialization diagnostics. A defined custom element is not a ready map. |
|
|
182
|
+
| Controls/map look unstyled | Check `skip-leaflet-styles`, CSS injection, CSP and shadow-root styling. In external mode use one compatible Leaflet namespace with Draw attached; set `leafletInstance` before connection. |
|
|
183
|
+
| Tool button missing or disabled | Read capability snapshot first; check enable attribute, read-only, plugin, and editable layers. Custom groups hide native toolbars by default. |
|
|
184
|
+
| Custom JSON toolbar ignored | Check diagnostic codes and JSON top-level shape. A property override wins over its attribute; set it to `undefined` to resume attribute configuration, `null` to clear. |
|
|
185
|
+
| Tiles changed unexpectedly | Inspect `tile-provider-error` and requested/active capabilities for OSM fallback. Named provider wins over `tile-url`. Attribute changes can replace an injected adapter. |
|
|
186
|
+
| HERE reports invalid key but key is correct | Classification is heuristic. Inspect network/CORS, restrictions, permissions and style; try permitted `lite.day` if satellite access fails. Never paste keys into issue reports. |
|
|
187
|
+
| Parent listener never receives an event | Subscribe on the actual element. Legacy draw/status/diagnostic events do not bubble; provider events are not composed. |
|
|
188
|
+
| Import did nothing | Wait for readiness; pre-controller methods are not queued. Catch promise failures; validate FC structure and coordinate order. Empty collection is valid, empty geometry is not. |
|
|
189
|
+
| Read-only still active | Remove `read-only`; a literal `"false"` attribute is still present. Read-only is interactive tool policy, not protection against host data API calls. |
|
|
190
|
+
| `prefer-canvas="false"` still uses Canvas | Boolean attribute presence is true. Set concrete-element `preferCanvas = false` before connection. |
|
|
191
|
+
| CSS cannot target a button inside `::part(toolbar-group)` | `::part` does not expose descendant selectors. Use button/icon parts, public tokens or trusted `themeCss`/`theme-url` rules. |
|
|
192
|
+
| Duplicate/missing toolbar controls | Any custom group with default/true `hideDefaultToolbar` hides native draw/ruler controls. Set false on every group to keep native controls; keep group IDs unique. |
|
|
193
|
+
| No developer overlay | `dev-overlay` is reserved; no overlay UI ships. Use public status/diagnostics and browser DevTools. |
|
|
194
|
+
| Reconnection loses a basemap or session | Disconnect destroys the controller. Preserve host data, wait for readiness, reload data, then reapply the adapter. |
|
|
195
|
+
|
|
196
|
+
## Logging and safe bug reports
|
|
197
|
+
|
|
198
|
+
Console levels are `trace`, `debug`, `info`, `warn`, `error`, `silent`; default is
|
|
199
|
+
`debug`. Configure an appropriate production level. Verbose logs can include
|
|
200
|
+
attribute values, tile URLs, GeoJSON and causes. General diagnostics are **not**
|
|
201
|
+
a credential-redaction boundary; only the dedicated provider/capability snapshots
|
|
202
|
+
intentionally omit keys/URLs/raw provider payloads. Even a message or status
|
|
203
|
+
`lastError.message` can contain a URL. Sanitize before sharing.
|
|
204
|
+
|
|
205
|
+
A useful report includes:
|
|
206
|
+
|
|
207
|
+
1. Package version/entrypoint, browser, bundled versus external runtime setup.
|
|
208
|
+
2. Minimal HTML/configuration with keys, private URLs, grower geometry and identifiers removed.
|
|
209
|
+
3. Diagnostic code/severity/state/recoverable, status transition, and tool command ID
|
|
210
|
+
when relevant; only sanitized message/cause excerpts.
|
|
211
|
+
4. Initial capability/configuration snapshots, reproduction steps, expected/actual behavior.
|
|
212
|
+
5. Whether it reproduces with OSM or deterministic local tiles and minimal valid GeoJSON.
|
|
213
|
+
|
|
214
|
+
Never include service credentials, unrestricted paid keys, complete request URLs
|
|
215
|
+
with tokens, raw exports, or unredacted screenshots/network archives. Follow
|
|
216
|
+
[provider security guidance](providers.md#security-and-vendor-independence).
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Grower-scale measurement accuracy
|
|
2
|
+
|
|
3
|
+
The existing ruler uses `computePreciseDistance` in `src/utils/geodesic.ts`.
|
|
4
|
+
Its Vincenty iteration must execute at least once even when longitude difference
|
|
5
|
+
is zero. Otherwise a north/south bed or irrigation row is reported as zero length.
|
|
6
|
+
The initial previous-longitude sentinel now guarantees that first evaluation;
|
|
7
|
+
the public API and units remain unchanged.
|
|
8
|
+
|
|
9
|
+
Regression coverage in `tests/geodesic.spec.ts` checks a same-meridian row in both
|
|
10
|
+
directions (about 11.0574276 m for 0.0001 degrees latitude at the equator), a nearly
|
|
11
|
+
meridional grower-scale segment, identical points, and the existing long-distance
|
|
12
|
+
cases.
|
|
13
|
+
|
|
14
|
+
Verified commands for this prerequisite:
|
|
15
|
+
|
|
16
|
+
- `npm run test:unit:focused -- tests/geodesic.spec.ts` — 15 tests passed.
|
|
17
|
+
- `npm run typecheck` — passed.
|
|
18
|
+
|
|
19
|
+
This is a prerequisite repair for FLOA-510, not delivery of snapping, geometry
|
|
20
|
+
operations, grower presets, or area/perimeter overlays. Those features require
|
|
21
|
+
separate implementation and desktop/touch interaction verification. Existing
|
|
22
|
+
irrigation geometry in `src/lib/layer-cake/CakeBaker.ts` and the layer-cake session
|
|
23
|
+
APIs should be reused rather than replaced.
|