@aiaiai-pt/design-system 0.26.0 → 0.27.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/components/MapPicker.svelte +17 -0
- package/package.json +1 -1
|
@@ -139,6 +139,23 @@
|
|
|
139
139
|
|
|
140
140
|
const boundaryRings = $derived(boundaryToRings(boundary));
|
|
141
141
|
|
|
142
|
+
// Recentre when `center` arrives or changes after mount. Consumers commonly
|
|
143
|
+
// resolve the centre asynchronously (after a boundary/config fetch), and the
|
|
144
|
+
// map-init effect reads `center` only PAST an `await`, so it is not tracked
|
|
145
|
+
// as a dependency there — without this the late centre is silently dropped
|
|
146
|
+
// and the map sits on its initial view (e.g. [0,0]). Skips once the user has
|
|
147
|
+
// placed a pin (`value`) so a late centre never yanks the map out from under
|
|
148
|
+
// a selection, and skips the [0,0] "unset" sentinel.
|
|
149
|
+
$effect(() => {
|
|
150
|
+
const c = center;
|
|
151
|
+
const map = _map;
|
|
152
|
+
if (!map || value) return;
|
|
153
|
+
if (!Array.isArray(c) || c.length !== 2) return;
|
|
154
|
+
if (c[0] === 0 && c[1] === 0) return;
|
|
155
|
+
const view = map.getView();
|
|
156
|
+
if (view) view.setCenter(fromLonLat(/** @type {[number, number]} */ (c)));
|
|
157
|
+
});
|
|
158
|
+
|
|
142
159
|
/** @param {[number, number]} coords */
|
|
143
160
|
function checkBoundary(coords) {
|
|
144
161
|
if (!boundaryRings.length || !onoutofbounds) return;
|