@fabriquerdemain/map-react 1.0.1 → 1.0.4

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.
@@ -11488,6 +11488,8 @@
11488
11488
  fitBoundsOnLoad: true,
11489
11489
  fitBoundsPadding: 50,
11490
11490
  showPopup: true,
11491
+ popupMode: "full",
11492
+ popupPlaceholder: "Détails bientôt disponibles",
11491
11493
  showPopupTitle: true,
11492
11494
  showPopupSubtitle: true,
11493
11495
  showPopupAddress: true,
@@ -11585,9 +11587,14 @@
11585
11587
  const markerMapRef = react.useRef(new globalThis.Map());
11586
11588
  const tileLayerRef = react.useRef(null);
11587
11589
  const hasFitBoundsRef = react.useRef(false);
11588
- const [currentTileSource, setCurrentTileSource] = react.useState(
11590
+ const currentTileSourceRef = react.useRef("ign");
11591
+ const [currentTileSource, setCurrentTileSourceState] = react.useState(
11589
11592
  "ign"
11590
11593
  );
11594
+ const setCurrentTileSource = react.useCallback((source) => {
11595
+ currentTileSourceRef.current = source;
11596
+ setCurrentTileSourceState(source);
11597
+ }, []);
11591
11598
  const config = { ...DEFAULT_MAP_CONFIG, ...configProp };
11592
11599
  const createColoredIcon = react.useCallback(
11593
11600
  (color = "#F95E3C") => {
@@ -11614,6 +11621,17 @@
11614
11621
  const buildPopupContent = react.useCallback(
11615
11622
  (marker) => {
11616
11623
  let html = '<div class="repcartes-popup">';
11624
+ if (config.popupMode === "minimal") {
11625
+ if (marker.subtitle) {
11626
+ html += `<p style="margin: 0 0 4px 0; font-size: 12px; color: #666; display: flex; align-items: center; gap: 4px;">
11627
+ <span style="font-size: 14px;">📍</span>
11628
+ ${marker.subtitle}
11629
+ </p>`;
11630
+ }
11631
+ html += `<p style="margin: 0; font-size: 11px; color: #999; font-style: italic;">${config.popupPlaceholder}</p>`;
11632
+ html += "</div>";
11633
+ return html;
11634
+ }
11617
11635
  if (config.showPopupTitle && marker.title) {
11618
11636
  html += `<h3 style="margin: 0 0 8px 0; font-size: 14px; font-weight: 600;">${marker.title}</h3>`;
11619
11637
  }
@@ -11680,9 +11698,9 @@
11680
11698
  });
11681
11699
  const center = map.getCenter();
11682
11700
  const shouldUseIgn = isInFrance(center.lat, center.lng);
11683
- if (shouldUseIgn && currentTileSource !== "ign") {
11701
+ if (shouldUseIgn && currentTileSourceRef.current !== "ign") {
11684
11702
  setCurrentTileSource("ign");
11685
- } else if (!shouldUseIgn && currentTileSource !== "osm") {
11703
+ } else if (!shouldUseIgn && currentTileSourceRef.current !== "osm") {
11686
11704
  setCurrentTileSource("osm");
11687
11705
  }
11688
11706
  });
@@ -11734,6 +11752,10 @@
11734
11752
  markersLayerRef.current.addLayer(marker);
11735
11753
  markerMapRef.current.set(markerData.id, marker);
11736
11754
  });
11755
+ const hasInternationalMarkers = markers.some((m) => !isInFrance(m.lat, m.lng));
11756
+ if (hasInternationalMarkers && currentTileSource === "ign") {
11757
+ setCurrentTileSource("osm");
11758
+ }
11737
11759
  if (config.fitBoundsOnLoad && markers.length > 0 && !hasFitBoundsRef.current) {
11738
11760
  const group = L$1.featureGroup(
11739
11761
  markers.map((m) => L$1.marker([m.lat, m.lng]))