@classic-homes/maps-react 0.6.0 → 0.7.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/README.md +20 -1
- package/dist/index.cjs +112 -48
- package/dist/index.css +142 -134
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +104 -38
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { MapProps, PositioningCoordinator, SourceProps, MarkerProps, PopupProps, FeatureClickEventParams, FeatureHoverEventParams, BaseLayerProps, FillLayerProps, LineLayerProps, CircleLayerProps, SymbolLayerProps, FillExtrusionLayerProps, HeatmapLayerProps, LegendProps, LegendGroupProps, CoordinateDisplayProps, BasemapSwitcherProps, LayerManagerProps, ExtendedControlPosition, ControlPriority, ZIndexLayer, MapTheme, MapStyleSpec, ControlType, ControlOffset } from '@classic-homes/maps-core';
|
|
3
3
|
export { BIKE_LANES, BUILTIN_BASEMAPS, BUILTIN_OVERLAY_LAYERS, BaseMapProps, BasemapApiKeys, BasemapCategory, BasemapDefinition, BasemapProvider, BasemapSwitcherProps, BoundsArray, CATEGORY_META, CITY_LIMITS, CircleLayerProps, ClusterCircleStyleOptions, ClusterExpandOptions, ClusterFeatureProperties, ClusterLayerStyles, ClusterTextStyleOptions, ControlOffset, ControlPriority, ControlType, CoordinateDisplayProps, DEFAULT_BASEMAP, ExtendedControlPosition, FLOOD_ZONES, FREE_BASEMAPS, FeatureClickEventParams, FeatureHoverEventParams, FillExtrusionLayerProps, FillLayerProps, GeoJSONFeature, GeoJSONFeatureCollection, GradientStop, HeatmapLayerProps, LayerManagerProps, LegendConfig, LegendGroupProps, LegendItem, LegendProps, LineLayerProps, LngLat, LoadGeoJSONOptions, LoadGeoJSONResult, MapBounds, MapClickEventParams, MapHoverEventParams, MapMoveEventParams, MapProps, MapViewport, MarkerClickEventParams, MarkerData, MarkerDragEventParams, MarkerProps, OSM_STANDARD, OverlayApiKeys, OverlayLayerCategory, OverlayLayerDefinition, OverlayLayerState, PARKS, PRIMARY_BASEMAPS, PopupProps, SATELLITE_BASEMAP, SCHOOL_DISTRICTS, SPORTS_FACILITIES, SourceProps, SymbolLayerProps, THEME_DARK, THEME_LIGHT, TOPO_BASEMAP, TRAILS, TRANSIT_ROUTES, UnclusteredPointStyleOptions, ValidationResult, WATERSHEDS, ZIndexLayer, ZONING_DISTRICTS, calculateBounds, calculateCentroid, combineBounds, countFeaturesByType, createClusterCirclePaint, createClusterStyles, createClusterTextLayout, createHoverExpression, createInitialLayerStates, createSelectionExpression, darkBasicStyle, darkTheme, expandCluster, expandClusterToBounds, extendBounds, filterByGeometryType, formatArea, formatCoordinates, formatDistance, generateMapDescription, getAvailableBasemaps, getClusterBounds, getClusterChildren, getClusterExpansionZoom, getClusterLeaves, getHighlightStyle, getLayerCategories, getLayerStyleForTheme, getLayersByCategory, getSelectionStyle, groupLayersByCategory, isClusterFeature, isValidBounds, lightBasicStyle, lightTheme, loadGeoJSON, resolveBasemapStyle, resolveLayerSourceUrl, searchLayers, setLayerOpacity, toggleLayerVisibility, validateGeoJSON } from '@classic-homes/maps-core';
|
|
4
|
-
import
|
|
4
|
+
import * as maplibregl from 'maplibre-gl';
|
|
5
|
+
import { Map as Map$1, StyleSpecification } from 'maplibre-gl';
|
|
5
6
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
7
|
import { VariantProps } from 'class-variance-authority';
|
|
7
8
|
import { ClassValue } from 'clsx';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { MapProps, PositioningCoordinator, SourceProps, MarkerProps, PopupProps, FeatureClickEventParams, FeatureHoverEventParams, BaseLayerProps, FillLayerProps, LineLayerProps, CircleLayerProps, SymbolLayerProps, FillExtrusionLayerProps, HeatmapLayerProps, LegendProps, LegendGroupProps, CoordinateDisplayProps, BasemapSwitcherProps, LayerManagerProps, ExtendedControlPosition, ControlPriority, ZIndexLayer, MapTheme, MapStyleSpec, ControlType, ControlOffset } from '@classic-homes/maps-core';
|
|
3
3
|
export { BIKE_LANES, BUILTIN_BASEMAPS, BUILTIN_OVERLAY_LAYERS, BaseMapProps, BasemapApiKeys, BasemapCategory, BasemapDefinition, BasemapProvider, BasemapSwitcherProps, BoundsArray, CATEGORY_META, CITY_LIMITS, CircleLayerProps, ClusterCircleStyleOptions, ClusterExpandOptions, ClusterFeatureProperties, ClusterLayerStyles, ClusterTextStyleOptions, ControlOffset, ControlPriority, ControlType, CoordinateDisplayProps, DEFAULT_BASEMAP, ExtendedControlPosition, FLOOD_ZONES, FREE_BASEMAPS, FeatureClickEventParams, FeatureHoverEventParams, FillExtrusionLayerProps, FillLayerProps, GeoJSONFeature, GeoJSONFeatureCollection, GradientStop, HeatmapLayerProps, LayerManagerProps, LegendConfig, LegendGroupProps, LegendItem, LegendProps, LineLayerProps, LngLat, LoadGeoJSONOptions, LoadGeoJSONResult, MapBounds, MapClickEventParams, MapHoverEventParams, MapMoveEventParams, MapProps, MapViewport, MarkerClickEventParams, MarkerData, MarkerDragEventParams, MarkerProps, OSM_STANDARD, OverlayApiKeys, OverlayLayerCategory, OverlayLayerDefinition, OverlayLayerState, PARKS, PRIMARY_BASEMAPS, PopupProps, SATELLITE_BASEMAP, SCHOOL_DISTRICTS, SPORTS_FACILITIES, SourceProps, SymbolLayerProps, THEME_DARK, THEME_LIGHT, TOPO_BASEMAP, TRAILS, TRANSIT_ROUTES, UnclusteredPointStyleOptions, ValidationResult, WATERSHEDS, ZIndexLayer, ZONING_DISTRICTS, calculateBounds, calculateCentroid, combineBounds, countFeaturesByType, createClusterCirclePaint, createClusterStyles, createClusterTextLayout, createHoverExpression, createInitialLayerStates, createSelectionExpression, darkBasicStyle, darkTheme, expandCluster, expandClusterToBounds, extendBounds, filterByGeometryType, formatArea, formatCoordinates, formatDistance, generateMapDescription, getAvailableBasemaps, getClusterBounds, getClusterChildren, getClusterExpansionZoom, getClusterLeaves, getHighlightStyle, getLayerCategories, getLayerStyleForTheme, getLayersByCategory, getSelectionStyle, groupLayersByCategory, isClusterFeature, isValidBounds, lightBasicStyle, lightTheme, loadGeoJSON, resolveBasemapStyle, resolveLayerSourceUrl, searchLayers, setLayerOpacity, toggleLayerVisibility, validateGeoJSON } from '@classic-homes/maps-core';
|
|
4
|
-
import
|
|
4
|
+
import * as maplibregl from 'maplibre-gl';
|
|
5
|
+
import { Map as Map$1, StyleSpecification } from 'maplibre-gl';
|
|
5
6
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
7
|
import { VariantProps } from 'class-variance-authority';
|
|
7
8
|
import { ClassValue } from 'clsx';
|
package/dist/index.js
CHANGED
|
@@ -3,11 +3,11 @@ import { useState, useEffect, useCallback } from 'react';
|
|
|
3
3
|
import { clsx } from 'clsx';
|
|
4
4
|
import { twMerge } from 'tailwind-merge';
|
|
5
5
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
6
|
-
import maplibregl from 'maplibre-gl';
|
|
6
|
+
import * as maplibregl from 'maplibre-gl';
|
|
7
7
|
import 'maplibre-gl/dist/maplibre-gl.css';
|
|
8
8
|
import '@classic-homes/maps-core/styles/controls.css';
|
|
9
9
|
import '@classic-homes/maps-core/styles/marker.css';
|
|
10
|
-
import { createPositioningCoordinator, generateMapDescription, applyMarkerProtection, applyMarkerChildProtection, removeMarkerProtection, DEFAULT_BASEMAP, darkTheme, lightTheme, THEME_DARK, THEME_LIGHT, calculateBounds, getChangedPaintProps, EDGE_MARGIN, formatCoordinates, getAvailableBasemaps, FREE_BASEMAPS, resolveBasemapThumbnail, createInitialLayerStates, getLayerCategories, searchLayers, groupLayersByCategory, toggleLayerVisibility, setLayerOpacity, getLayerStatesArray, reorderLayers, CATEGORY_META, resolveBasemapStyle, getGridNavigationIndex, STACK_GAP, getLayerStyleForTheme, resolveLayerSourceUrl } from '@classic-homes/maps-core';
|
|
10
|
+
import { createPositioningCoordinator, generateMapDescription, warnIfWorkerUrlMissing, applyMarkerProtection, applyMarkerChildProtection, removeMarkerProtection, DEFAULT_BASEMAP, darkTheme, lightTheme, THEME_DARK, THEME_LIGHT, calculateBounds, getChangedPaintProps, EDGE_MARGIN, formatCoordinates, getAvailableBasemaps, FREE_BASEMAPS, resolveBasemapThumbnail, createInitialLayerStates, getLayerCategories, searchLayers, groupLayersByCategory, toggleLayerVisibility, setLayerOpacity, getLayerStatesArray, reorderLayers, CATEGORY_META, resolveBasemapStyle, getGridNavigationIndex, STACK_GAP, getLayerStyleForTheme, resolveLayerSourceUrl } from '@classic-homes/maps-core';
|
|
11
11
|
export { BIKE_LANES, BUILTIN_BASEMAPS, BUILTIN_OVERLAY_LAYERS, CATEGORY_META, CITY_LIMITS, DEFAULT_BASEMAP, FLOOD_ZONES, FREE_BASEMAPS, OSM_STANDARD, PARKS, PRIMARY_BASEMAPS, SATELLITE_BASEMAP, SCHOOL_DISTRICTS, SPORTS_FACILITIES, THEME_DARK, THEME_LIGHT, TOPO_BASEMAP, TRAILS, TRANSIT_ROUTES, WATERSHEDS, ZONING_DISTRICTS, calculateBounds, calculateCentroid, combineBounds, countFeaturesByType, createClusterCirclePaint, createClusterStyles, createClusterTextLayout, createHoverExpression, createInitialLayerStates, createSelectionExpression, darkBasicStyle, darkTheme, expandCluster, expandClusterToBounds, extendBounds, filterByGeometryType, formatArea, formatCoordinates, formatDistance, generateMapDescription, getAvailableBasemaps, getClusterBounds, getClusterChildren, getClusterExpansionZoom, getClusterLeaves, getHighlightStyle, getLayerCategories, getLayerStyleForTheme, getLayersByCategory, getSelectionStyle, groupLayersByCategory, isClusterFeature, isValidBounds, lightBasicStyle, lightTheme, loadGeoJSON, resolveBasemapStyle, resolveLayerSourceUrl, searchLayers, setLayerOpacity, toggleLayerVisibility, validateGeoJSON } from '@classic-homes/maps-core';
|
|
12
12
|
import * as ReactDOM from 'react-dom';
|
|
13
13
|
import { panToFitPopup, normalizePadding } from '@classic-homes/maps-core/utils';
|
|
@@ -295,7 +295,7 @@ function getStyleKey(style) {
|
|
|
295
295
|
if (!style) return "";
|
|
296
296
|
return typeof style === "string" ? style : JSON.stringify(style);
|
|
297
297
|
}
|
|
298
|
-
var
|
|
298
|
+
var Map3 = React6.forwardRef(
|
|
299
299
|
({
|
|
300
300
|
// Base props
|
|
301
301
|
title,
|
|
@@ -425,6 +425,7 @@ var Map2 = React6.forwardRef(
|
|
|
425
425
|
React6.useEffect(() => {
|
|
426
426
|
if (!containerRef.current || mapRef.current) return;
|
|
427
427
|
try {
|
|
428
|
+
warnIfWorkerUrlMissing(maplibregl);
|
|
428
429
|
const map = new maplibregl.Map({
|
|
429
430
|
container: containerRef.current,
|
|
430
431
|
style: mapStyle,
|
|
@@ -734,8 +735,54 @@ var Map2 = React6.forwardRef(
|
|
|
734
735
|
);
|
|
735
736
|
}
|
|
736
737
|
);
|
|
737
|
-
|
|
738
|
-
|
|
738
|
+
Map3.displayName = "Map";
|
|
739
|
+
function createSourceRegistry() {
|
|
740
|
+
const versions = /* @__PURE__ */ new Map();
|
|
741
|
+
const stacking = /* @__PURE__ */ new Map();
|
|
742
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
743
|
+
let counter = 0;
|
|
744
|
+
const notify = () => {
|
|
745
|
+
for (const listener of [...listeners]) listener();
|
|
746
|
+
};
|
|
747
|
+
return {
|
|
748
|
+
version: (id) => versions.get(id) ?? 0,
|
|
749
|
+
added(id) {
|
|
750
|
+
versions.set(id, ++counter);
|
|
751
|
+
notify();
|
|
752
|
+
},
|
|
753
|
+
removed(id, layersAbove) {
|
|
754
|
+
stacking.set(id, layersAbove ?? /* @__PURE__ */ new Map());
|
|
755
|
+
if (versions.delete(id)) notify();
|
|
756
|
+
},
|
|
757
|
+
layersAbove: (sourceId, layerId) => stacking.get(sourceId)?.get(layerId) ?? [],
|
|
758
|
+
subscribe(listener) {
|
|
759
|
+
listeners.add(listener);
|
|
760
|
+
return () => {
|
|
761
|
+
listeners.delete(listener);
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
var registries = /* @__PURE__ */ new WeakMap();
|
|
767
|
+
function getSourceRegistry(map) {
|
|
768
|
+
let registry = registries.get(map);
|
|
769
|
+
if (!registry) {
|
|
770
|
+
registry = createSourceRegistry();
|
|
771
|
+
registries.set(map, registry);
|
|
772
|
+
}
|
|
773
|
+
return registry;
|
|
774
|
+
}
|
|
775
|
+
var noopSubscribe = () => () => {
|
|
776
|
+
};
|
|
777
|
+
var zero = () => 0;
|
|
778
|
+
function useSourceVersion(map, sourceId) {
|
|
779
|
+
const registry = map ? getSourceRegistry(map) : null;
|
|
780
|
+
const getSnapshot = React6.useCallback(
|
|
781
|
+
() => registry ? registry.version(sourceId) : 0,
|
|
782
|
+
[registry, sourceId]
|
|
783
|
+
);
|
|
784
|
+
return React6.useSyncExternalStore(registry?.subscribe ?? noopSubscribe, getSnapshot, zero);
|
|
785
|
+
}
|
|
739
786
|
var Source = ({
|
|
740
787
|
id,
|
|
741
788
|
type,
|
|
@@ -758,7 +805,6 @@ var Source = ({
|
|
|
758
805
|
const { map, loaded, styleVersion } = useMap();
|
|
759
806
|
const initialFitDone = React6.useRef(false);
|
|
760
807
|
const appliedDataRef = React6.useRef(void 0);
|
|
761
|
-
const [sourceVersion, setSourceVersion] = React6.useState(0);
|
|
762
808
|
const fitBoundsParamsRef = React6.useRef({
|
|
763
809
|
shouldFitBounds,
|
|
764
810
|
data,
|
|
@@ -909,7 +955,8 @@ var Source = ({
|
|
|
909
955
|
map.once("idle", handleIdle);
|
|
910
956
|
map.addSource(id, sourceConfig);
|
|
911
957
|
appliedDataRef.current = type === "geojson" ? data : void 0;
|
|
912
|
-
|
|
958
|
+
const registry = getSourceRegistry(map);
|
|
959
|
+
registry.added(id);
|
|
913
960
|
const source = map.getSource(id);
|
|
914
961
|
if (source && map.isSourceLoaded(id)) {
|
|
915
962
|
map.off("sourcedata", handleSourceData);
|
|
@@ -928,11 +975,14 @@ var Source = ({
|
|
|
928
975
|
return () => {
|
|
929
976
|
cleanupListeners();
|
|
930
977
|
if (map) {
|
|
978
|
+
const layersAbove = /* @__PURE__ */ new Map();
|
|
931
979
|
try {
|
|
932
980
|
const style = map.getStyle();
|
|
933
981
|
if (style?.layers) {
|
|
934
|
-
style.layers.
|
|
982
|
+
const ids = style.layers.map((layer) => layer.id);
|
|
983
|
+
style.layers.forEach((layer, index) => {
|
|
935
984
|
if ("source" in layer && layer.source === id) {
|
|
985
|
+
layersAbove.set(layer.id, ids.slice(index + 1));
|
|
936
986
|
if (map.getLayer(layer.id)) {
|
|
937
987
|
map.removeLayer(layer.id);
|
|
938
988
|
}
|
|
@@ -944,6 +994,7 @@ var Source = ({
|
|
|
944
994
|
}
|
|
945
995
|
} catch {
|
|
946
996
|
}
|
|
997
|
+
registry.removed(id, layersAbove);
|
|
947
998
|
}
|
|
948
999
|
};
|
|
949
1000
|
} catch (err) {
|
|
@@ -999,11 +1050,10 @@ var Source = ({
|
|
|
999
1050
|
console.error(`[maps-react] Failed to update source "${id}" data:`, err);
|
|
1000
1051
|
}
|
|
1001
1052
|
}, [map, loaded, id, type, data, cluster]);
|
|
1002
|
-
|
|
1003
|
-
return /* @__PURE__ */ jsx(SourceContext.Provider, { value: sourceContext, children });
|
|
1053
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
1004
1054
|
};
|
|
1005
1055
|
Source.displayName = "Source";
|
|
1006
|
-
var
|
|
1056
|
+
var Marker2 = React6.forwardRef(
|
|
1007
1057
|
({
|
|
1008
1058
|
id,
|
|
1009
1059
|
coordinates,
|
|
@@ -1215,7 +1265,7 @@ var Marker = React6.forwardRef(
|
|
|
1215
1265
|
return null;
|
|
1216
1266
|
}
|
|
1217
1267
|
);
|
|
1218
|
-
|
|
1268
|
+
Marker2.displayName = "Marker";
|
|
1219
1269
|
function useStructuralValue(next) {
|
|
1220
1270
|
const ref = React6.useRef(next);
|
|
1221
1271
|
if (ref.current !== next && JSON.stringify(ref.current) !== JSON.stringify(next)) {
|
|
@@ -1223,7 +1273,7 @@ function useStructuralValue(next) {
|
|
|
1223
1273
|
}
|
|
1224
1274
|
return ref.current;
|
|
1225
1275
|
}
|
|
1226
|
-
var
|
|
1276
|
+
var Popup2 = React6.forwardRef(
|
|
1227
1277
|
({
|
|
1228
1278
|
coordinates: coordinatesProp,
|
|
1229
1279
|
closeButton = true,
|
|
@@ -1346,7 +1396,7 @@ var Popup = React6.forwardRef(
|
|
|
1346
1396
|
);
|
|
1347
1397
|
}
|
|
1348
1398
|
);
|
|
1349
|
-
|
|
1399
|
+
Popup2.displayName = "Popup";
|
|
1350
1400
|
var PopupCard = React6.forwardRef(
|
|
1351
1401
|
({ className, children, ...props }, ref) => {
|
|
1352
1402
|
return /* @__PURE__ */ jsx("div", { ref, className: cn("bg-popover text-popover-foreground", className), ...props, children });
|
|
@@ -1433,14 +1483,16 @@ function useLayer({
|
|
|
1433
1483
|
hoverThrottleMs = 0
|
|
1434
1484
|
}) {
|
|
1435
1485
|
const { map, loaded, styleVersion } = useMap();
|
|
1436
|
-
const
|
|
1437
|
-
const sourceVersion = sourceContext?.id === source ? sourceContext.version : 0;
|
|
1486
|
+
const sourceVersion = useSourceVersion(map, source);
|
|
1438
1487
|
const [layerAdded, setLayerAdded] = React6.useState(false);
|
|
1439
1488
|
const hoveredFeatureId = React6.useRef(null);
|
|
1440
1489
|
const lastHoverCallTime = React6.useRef(0);
|
|
1441
1490
|
const lastMousePosition = React6.useRef(null);
|
|
1442
1491
|
const lastAppliedPaintRef = React6.useRef(void 0);
|
|
1443
1492
|
const lastAppliedLayoutRef = React6.useRef(void 0);
|
|
1493
|
+
const latestRef = React6.useRef({ visible, minZoom, maxZoom, filter, paint, layout });
|
|
1494
|
+
latestRef.current = { visible, minZoom, maxZoom, filter, paint, layout };
|
|
1495
|
+
const restoreLayerRef = React6.useRef(null);
|
|
1444
1496
|
React6.useEffect(() => {
|
|
1445
1497
|
hoveredFeatureId.current = null;
|
|
1446
1498
|
}, [styleVersion]);
|
|
@@ -1448,52 +1500,63 @@ function useLayer({
|
|
|
1448
1500
|
if (!map || !loaded) return;
|
|
1449
1501
|
let added = false;
|
|
1450
1502
|
let timeoutId = null;
|
|
1451
|
-
const
|
|
1503
|
+
const stopWaiting = () => {
|
|
1504
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
1505
|
+
timeoutId = null;
|
|
1506
|
+
map.off("sourcedata", checkSource);
|
|
1507
|
+
};
|
|
1508
|
+
function checkSource() {
|
|
1452
1509
|
if (map.getSource(source)) {
|
|
1453
|
-
|
|
1454
|
-
timeoutId = null;
|
|
1455
|
-
map.off("sourcedata", checkSource);
|
|
1510
|
+
stopWaiting();
|
|
1456
1511
|
addLayer();
|
|
1457
1512
|
}
|
|
1458
|
-
}
|
|
1459
|
-
function addLayer() {
|
|
1513
|
+
}
|
|
1514
|
+
function addLayer(insertBefore = beforeId) {
|
|
1460
1515
|
if (map.getLayer(id)) {
|
|
1461
1516
|
added = true;
|
|
1462
1517
|
setLayerAdded(true);
|
|
1463
1518
|
return;
|
|
1464
1519
|
}
|
|
1520
|
+
const { visible: visible2, minZoom: minZoom2, maxZoom: maxZoom2, filter: filter2, paint: paint2, layout: layout2 } = latestRef.current;
|
|
1465
1521
|
try {
|
|
1466
1522
|
const layerConfig = {
|
|
1467
1523
|
id,
|
|
1468
1524
|
type,
|
|
1469
1525
|
source,
|
|
1470
|
-
paint,
|
|
1526
|
+
paint: paint2,
|
|
1471
1527
|
layout: {
|
|
1472
|
-
visibility:
|
|
1473
|
-
...
|
|
1528
|
+
visibility: visible2 ? "visible" : "none",
|
|
1529
|
+
...layout2
|
|
1474
1530
|
}
|
|
1475
1531
|
};
|
|
1476
1532
|
if (sourceLayer) {
|
|
1477
1533
|
layerConfig["source-layer"] = sourceLayer;
|
|
1478
1534
|
}
|
|
1479
|
-
if (
|
|
1480
|
-
layerConfig.minzoom =
|
|
1535
|
+
if (minZoom2 !== void 0) {
|
|
1536
|
+
layerConfig.minzoom = minZoom2;
|
|
1481
1537
|
}
|
|
1482
|
-
if (
|
|
1483
|
-
layerConfig.maxzoom =
|
|
1538
|
+
if (maxZoom2 !== void 0) {
|
|
1539
|
+
layerConfig.maxzoom = maxZoom2;
|
|
1484
1540
|
}
|
|
1485
|
-
if (
|
|
1486
|
-
layerConfig.filter =
|
|
1541
|
+
if (filter2) {
|
|
1542
|
+
layerConfig.filter = filter2;
|
|
1487
1543
|
}
|
|
1488
|
-
map.addLayer(layerConfig,
|
|
1544
|
+
map.addLayer(layerConfig, insertBefore);
|
|
1489
1545
|
added = true;
|
|
1490
|
-
lastAppliedPaintRef.current = { ...
|
|
1491
|
-
lastAppliedLayoutRef.current = withoutVisibility(
|
|
1546
|
+
lastAppliedPaintRef.current = { ...paint2 };
|
|
1547
|
+
lastAppliedLayoutRef.current = withoutVisibility(layout2);
|
|
1492
1548
|
setLayerAdded(true);
|
|
1493
1549
|
} catch (err) {
|
|
1494
1550
|
console.error(`[maps-react] Failed to add layer "${id}":`, err);
|
|
1495
1551
|
}
|
|
1496
1552
|
}
|
|
1553
|
+
restoreLayerRef.current = () => {
|
|
1554
|
+
if (map.getLayer(id) || !map.getSource(source)) return;
|
|
1555
|
+
hoveredFeatureId.current = null;
|
|
1556
|
+
stopWaiting();
|
|
1557
|
+
const above = beforeId ? void 0 : getSourceRegistry(map).layersAbove(source, id).find((layerId) => map.getLayer(layerId));
|
|
1558
|
+
addLayer(beforeId ?? above);
|
|
1559
|
+
};
|
|
1497
1560
|
if (map.getSource(source)) {
|
|
1498
1561
|
addLayer();
|
|
1499
1562
|
} else {
|
|
@@ -1507,8 +1570,8 @@ function useLayer({
|
|
|
1507
1570
|
map.on("sourcedata", checkSource);
|
|
1508
1571
|
}
|
|
1509
1572
|
return () => {
|
|
1510
|
-
|
|
1511
|
-
|
|
1573
|
+
restoreLayerRef.current = null;
|
|
1574
|
+
stopWaiting();
|
|
1512
1575
|
if (added) {
|
|
1513
1576
|
try {
|
|
1514
1577
|
if (map.getLayer(id)) {
|
|
@@ -1519,7 +1582,10 @@ function useLayer({
|
|
|
1519
1582
|
}
|
|
1520
1583
|
setLayerAdded(false);
|
|
1521
1584
|
};
|
|
1522
|
-
}, [map, loaded, id, source, sourceLayer, type, beforeId, styleVersion
|
|
1585
|
+
}, [map, loaded, id, source, sourceLayer, type, beforeId, styleVersion]);
|
|
1586
|
+
React6.useEffect(() => {
|
|
1587
|
+
if (sourceVersion) restoreLayerRef.current?.();
|
|
1588
|
+
}, [sourceVersion]);
|
|
1523
1589
|
React6.useEffect(() => {
|
|
1524
1590
|
if (!map || !layerAdded) return;
|
|
1525
1591
|
if (!map.getLayer(id)) return;
|
|
@@ -3557,4 +3623,4 @@ var DeckOverlay = ({
|
|
|
3557
3623
|
};
|
|
3558
3624
|
DeckOverlay.displayName = "DeckOverlay";
|
|
3559
3625
|
|
|
3560
|
-
export { BasemapSwitcher, CircleLayer, CoordinateDisplay, CustomControl, DeckOverlay, FillExtrusionLayer, FillLayer, HeatmapLayer, LayerManager, Legend, LegendGroup, LineLayer,
|
|
3626
|
+
export { BasemapSwitcher, CircleLayer, CoordinateDisplay, CustomControl, DeckOverlay, FillExtrusionLayer, FillLayer, HeatmapLayer, LayerManager, Legend, LegendGroup, LineLayer, Map3 as Map, MapContainer, MapContext, MapEmpty, MapError, MapSkeleton, Marker2 as Marker, Popup2 as Popup, PopupCard, PopupContent, PopupFooter, PopupHeader, Source, SymbolLayer, cn, useControlPosition, useCustomControl, useLayer, useMap, useMapInstance, useMapTheme, useReducedMotion };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@classic-homes/maps-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "React MapLibre components for Classic Theme",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"maps",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@deck.gl/core": "^9.0.0",
|
|
57
57
|
"@deck.gl/layers": "^9.0.0",
|
|
58
58
|
"@deck.gl/mapbox": "^9.0.0",
|
|
59
|
-
"maplibre-gl": "^
|
|
59
|
+
"maplibre-gl": "^5.0.0 || ^6.11.0",
|
|
60
60
|
"react": "^18.0.0 || ^19.0.0",
|
|
61
61
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
62
62
|
},
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"@types/react": "^18.2.0",
|
|
79
79
|
"@types/react-dom": "^18.2.0",
|
|
80
80
|
"jsdom": "^28.1.0",
|
|
81
|
-
"maplibre-gl": "^
|
|
81
|
+
"maplibre-gl": "^6.14.0",
|
|
82
82
|
"react": "^18.2.0",
|
|
83
83
|
"react-dom": "^18.2.0",
|
|
84
84
|
"tsup": "^8.0.0",
|