@classic-homes/maps-react 0.2.13 → 0.2.16
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/index.cjs +23 -4
- package/dist/index.js +24 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -347,6 +347,7 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
347
347
|
doubleClickZoom = true,
|
|
348
348
|
touchZoomRotate = true,
|
|
349
349
|
keyboard = true,
|
|
350
|
+
cooperativeGestures,
|
|
350
351
|
attributionControl = true,
|
|
351
352
|
customAttribution,
|
|
352
353
|
navigationControl = true,
|
|
@@ -444,6 +445,7 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
444
445
|
doubleClickZoom,
|
|
445
446
|
touchZoomRotate,
|
|
446
447
|
keyboard,
|
|
448
|
+
cooperativeGestures,
|
|
447
449
|
attributionControl: attributionControl ? { customAttribution } : false
|
|
448
450
|
});
|
|
449
451
|
mapRef.current = map;
|
|
@@ -1181,6 +1183,11 @@ var Marker = React26__namespace.forwardRef(
|
|
|
1181
1183
|
markerRef.current.setRotation(rotation);
|
|
1182
1184
|
}
|
|
1183
1185
|
}, [rotation]);
|
|
1186
|
+
React26__namespace.useEffect(() => {
|
|
1187
|
+
if (markerRef.current && offset) {
|
|
1188
|
+
markerRef.current.setOffset(offset);
|
|
1189
|
+
}
|
|
1190
|
+
}, [offset]);
|
|
1184
1191
|
if (children && elementRef.current) {
|
|
1185
1192
|
return ReactDOM__namespace.createPortal(children, elementRef.current);
|
|
1186
1193
|
}
|
|
@@ -1470,12 +1477,22 @@ function useLayer({
|
|
|
1470
1477
|
if (!map.getLayer(id)) return;
|
|
1471
1478
|
map.setLayoutProperty(id, "visibility", visible ? "visible" : "none");
|
|
1472
1479
|
}, [map, id, visible, layerAdded]);
|
|
1480
|
+
const lastAppliedPaintRef = React26__namespace.useRef(void 0);
|
|
1473
1481
|
React26__namespace.useEffect(() => {
|
|
1474
1482
|
if (!map || !layerAdded) return;
|
|
1475
1483
|
if (!map.getLayer(id)) return;
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1484
|
+
const diff = mapsCore.getChangedPaintProps(lastAppliedPaintRef.current, paint);
|
|
1485
|
+
if (!diff.hasChanges) return;
|
|
1486
|
+
try {
|
|
1487
|
+
for (const [key, value] of Object.entries(diff.changed)) {
|
|
1488
|
+
map.setPaintProperty(id, key, value);
|
|
1489
|
+
}
|
|
1490
|
+
for (const key of diff.removed) {
|
|
1491
|
+
map.setPaintProperty(id, key, void 0);
|
|
1492
|
+
}
|
|
1493
|
+
lastAppliedPaintRef.current = paint ? { ...paint } : void 0;
|
|
1494
|
+
} catch {
|
|
1495
|
+
}
|
|
1479
1496
|
}, [map, id, paint, layerAdded]);
|
|
1480
1497
|
React26__namespace.useEffect(() => {
|
|
1481
1498
|
if (!map || !layerAdded || !filter) return;
|
|
@@ -3366,6 +3383,8 @@ var DeckOverlay = ({
|
|
|
3366
3383
|
const { map, loaded } = useMap();
|
|
3367
3384
|
const overlayRef = React26__namespace.useRef(null);
|
|
3368
3385
|
const MapboxOverlayRef = React26__namespace.useRef(null);
|
|
3386
|
+
const layersRef = React26__namespace.useRef(layers);
|
|
3387
|
+
layersRef.current = layers;
|
|
3369
3388
|
React26__namespace.useEffect(() => {
|
|
3370
3389
|
if (!map || !loaded) return;
|
|
3371
3390
|
let cancelled = false;
|
|
@@ -3377,7 +3396,7 @@ var DeckOverlay = ({
|
|
|
3377
3396
|
MapboxOverlayRef.current = MapboxOverlay;
|
|
3378
3397
|
const overlay = new MapboxOverlay({
|
|
3379
3398
|
interleaved,
|
|
3380
|
-
layers,
|
|
3399
|
+
layers: layersRef.current,
|
|
3381
3400
|
onHover,
|
|
3382
3401
|
onClick,
|
|
3383
3402
|
...getCursor ? { getCursor } : {},
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import 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, EDGE_MARGIN, formatCoordinates, getAvailableBasemaps, FREE_BASEMAPS, resolveBasemapThumbnail, createInitialLayerStates, getLayerCategories, searchLayers, groupLayersByCategory, toggleLayerVisibility, setLayerOpacity, getLayerStatesArray, reorderLayers, CATEGORY_META, resolveBasemapStyle, STACK_GAP, getLayerStyleForTheme, resolveLayerSourceUrl } from '@classic-homes/maps-core';
|
|
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, 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';
|
|
@@ -323,6 +323,7 @@ var Map2 = React26.forwardRef(
|
|
|
323
323
|
doubleClickZoom = true,
|
|
324
324
|
touchZoomRotate = true,
|
|
325
325
|
keyboard = true,
|
|
326
|
+
cooperativeGestures,
|
|
326
327
|
attributionControl = true,
|
|
327
328
|
customAttribution,
|
|
328
329
|
navigationControl = true,
|
|
@@ -420,6 +421,7 @@ var Map2 = React26.forwardRef(
|
|
|
420
421
|
doubleClickZoom,
|
|
421
422
|
touchZoomRotate,
|
|
422
423
|
keyboard,
|
|
424
|
+
cooperativeGestures,
|
|
423
425
|
attributionControl: attributionControl ? { customAttribution } : false
|
|
424
426
|
});
|
|
425
427
|
mapRef.current = map;
|
|
@@ -1157,6 +1159,11 @@ var Marker = React26.forwardRef(
|
|
|
1157
1159
|
markerRef.current.setRotation(rotation);
|
|
1158
1160
|
}
|
|
1159
1161
|
}, [rotation]);
|
|
1162
|
+
React26.useEffect(() => {
|
|
1163
|
+
if (markerRef.current && offset) {
|
|
1164
|
+
markerRef.current.setOffset(offset);
|
|
1165
|
+
}
|
|
1166
|
+
}, [offset]);
|
|
1160
1167
|
if (children && elementRef.current) {
|
|
1161
1168
|
return ReactDOM.createPortal(children, elementRef.current);
|
|
1162
1169
|
}
|
|
@@ -1446,12 +1453,22 @@ function useLayer({
|
|
|
1446
1453
|
if (!map.getLayer(id)) return;
|
|
1447
1454
|
map.setLayoutProperty(id, "visibility", visible ? "visible" : "none");
|
|
1448
1455
|
}, [map, id, visible, layerAdded]);
|
|
1456
|
+
const lastAppliedPaintRef = React26.useRef(void 0);
|
|
1449
1457
|
React26.useEffect(() => {
|
|
1450
1458
|
if (!map || !layerAdded) return;
|
|
1451
1459
|
if (!map.getLayer(id)) return;
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1460
|
+
const diff = getChangedPaintProps(lastAppliedPaintRef.current, paint);
|
|
1461
|
+
if (!diff.hasChanges) return;
|
|
1462
|
+
try {
|
|
1463
|
+
for (const [key, value] of Object.entries(diff.changed)) {
|
|
1464
|
+
map.setPaintProperty(id, key, value);
|
|
1465
|
+
}
|
|
1466
|
+
for (const key of diff.removed) {
|
|
1467
|
+
map.setPaintProperty(id, key, void 0);
|
|
1468
|
+
}
|
|
1469
|
+
lastAppliedPaintRef.current = paint ? { ...paint } : void 0;
|
|
1470
|
+
} catch {
|
|
1471
|
+
}
|
|
1455
1472
|
}, [map, id, paint, layerAdded]);
|
|
1456
1473
|
React26.useEffect(() => {
|
|
1457
1474
|
if (!map || !layerAdded || !filter) return;
|
|
@@ -3342,6 +3359,8 @@ var DeckOverlay = ({
|
|
|
3342
3359
|
const { map, loaded } = useMap();
|
|
3343
3360
|
const overlayRef = React26.useRef(null);
|
|
3344
3361
|
const MapboxOverlayRef = React26.useRef(null);
|
|
3362
|
+
const layersRef = React26.useRef(layers);
|
|
3363
|
+
layersRef.current = layers;
|
|
3345
3364
|
React26.useEffect(() => {
|
|
3346
3365
|
if (!map || !loaded) return;
|
|
3347
3366
|
let cancelled = false;
|
|
@@ -3353,7 +3372,7 @@ var DeckOverlay = ({
|
|
|
3353
3372
|
MapboxOverlayRef.current = MapboxOverlay;
|
|
3354
3373
|
const overlay = new MapboxOverlay({
|
|
3355
3374
|
interleaved,
|
|
3356
|
-
layers,
|
|
3375
|
+
layers: layersRef.current,
|
|
3357
3376
|
onHover,
|
|
3358
3377
|
onClick,
|
|
3359
3378
|
...getCursor ? { getCursor } : {},
|