@fabriquerdemain/map-react 1.0.0 → 1.0.2
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/dist/components/Filters.d.ts +6 -2
- package/dist/components/Filters.d.ts.map +1 -1
- package/dist/components/Map.d.ts.map +1 -1
- package/dist/hooks/useMapFilters.d.ts +5 -1
- package/dist/hooks/useMapFilters.d.ts.map +1 -1
- package/dist/repcartes-map-react.js +25 -5
- package/dist/repcartes-map-react.js.map +1 -1
- package/dist/repcartes-map-react.umd.cjs +25 -5
- package/dist/repcartes-map-react.umd.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -11584,6 +11584,7 @@
|
|
|
11584
11584
|
const markersLayerRef = react.useRef(null);
|
|
11585
11585
|
const markerMapRef = react.useRef(new globalThis.Map());
|
|
11586
11586
|
const tileLayerRef = react.useRef(null);
|
|
11587
|
+
const hasFitBoundsRef = react.useRef(false);
|
|
11587
11588
|
const [currentTileSource, setCurrentTileSource] = react.useState(
|
|
11588
11589
|
"ign"
|
|
11589
11590
|
);
|
|
@@ -11733,11 +11734,21 @@
|
|
|
11733
11734
|
markersLayerRef.current.addLayer(marker);
|
|
11734
11735
|
markerMapRef.current.set(markerData.id, marker);
|
|
11735
11736
|
});
|
|
11736
|
-
if (config.fitBoundsOnLoad && markers.length > 0) {
|
|
11737
|
+
if (config.fitBoundsOnLoad && markers.length > 0 && !hasFitBoundsRef.current) {
|
|
11737
11738
|
const group = L$1.featureGroup(
|
|
11738
11739
|
markers.map((m) => L$1.marker([m.lat, m.lng]))
|
|
11739
11740
|
);
|
|
11740
11741
|
(_a = mapRef.current) == null ? void 0 : _a.fitBounds(group.getBounds(), { padding: [50, 50] });
|
|
11742
|
+
hasFitBoundsRef.current = true;
|
|
11743
|
+
setTimeout(() => {
|
|
11744
|
+
if (mapRef.current) {
|
|
11745
|
+
const center = mapRef.current.getCenter();
|
|
11746
|
+
const shouldUseIgn = isInFrance(center.lat, center.lng);
|
|
11747
|
+
if (!shouldUseIgn) {
|
|
11748
|
+
setCurrentTileSource("osm");
|
|
11749
|
+
}
|
|
11750
|
+
}
|
|
11751
|
+
}, 100);
|
|
11741
11752
|
}
|
|
11742
11753
|
}, [
|
|
11743
11754
|
markers,
|
|
@@ -12078,7 +12089,12 @@
|
|
|
12078
12089
|
value: key,
|
|
12079
12090
|
label: dt.label,
|
|
12080
12091
|
color: dt.color
|
|
12081
|
-
})) : types.map((t) =>
|
|
12092
|
+
})) : types.map((t) => {
|
|
12093
|
+
if (typeof t === "string") {
|
|
12094
|
+
return { value: t, label: t };
|
|
12095
|
+
}
|
|
12096
|
+
return t;
|
|
12097
|
+
});
|
|
12082
12098
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12083
12099
|
"div",
|
|
12084
12100
|
{
|
|
@@ -12255,13 +12271,17 @@
|
|
|
12255
12271
|
return Array.from(cities).sort();
|
|
12256
12272
|
}, [markers]);
|
|
12257
12273
|
const availableTypes = react.useMemo(() => {
|
|
12258
|
-
const
|
|
12274
|
+
const typesMap = /* @__PURE__ */ new Map();
|
|
12259
12275
|
markers.forEach((m) => {
|
|
12260
12276
|
if (m.type) {
|
|
12261
|
-
|
|
12277
|
+
typesMap.set(m.type, {
|
|
12278
|
+
value: m.type,
|
|
12279
|
+
label: m.typeLabel || m.type,
|
|
12280
|
+
color: m.typeColor
|
|
12281
|
+
});
|
|
12262
12282
|
}
|
|
12263
12283
|
});
|
|
12264
|
-
return Array.from(
|
|
12284
|
+
return Array.from(typesMap.values()).sort((a, b) => a.label.localeCompare(b.label));
|
|
12265
12285
|
}, [markers]);
|
|
12266
12286
|
const totalCount = markers.length;
|
|
12267
12287
|
const filteredCount = filteredMarkers.length;
|