@trackunit/react-map 0.1.22 → 0.1.25
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/index.cjs.js +312 -130
- package/index.esm.js +307 -126
- package/package.json +11 -11
- package/src/cursor/useEntitiesNearCursor.d.ts +36 -0
- package/src/index.d.ts +2 -1
- package/src/layers/shared/measureLabelWidth.d.ts +8 -6
- package/src/layers/useShapes/buildShapeLabelResolutionContext.d.ts +6 -7
- package/src/layers/useShapes/edge/findBestEdgePosition.d.ts +0 -7
- package/src/layers/useShapes/shapeFillTiling.d.ts +0 -1
- package/src/layers/useShapes/shapeStackOrder.d.ts +3 -10
- package/src/markers/shared/mapMarkerVariants.d.ts +3 -3
package/index.esm.js
CHANGED
|
@@ -15,7 +15,7 @@ import { useModal, Modal as Modal$1, ModalHeader, ModalBody } from '@trackunit/r
|
|
|
15
15
|
import { z } from 'zod';
|
|
16
16
|
import { PieChart } from 'react-minimal-pie-chart';
|
|
17
17
|
import { tailwindPalette } from '@trackunit/ui-design-tokens';
|
|
18
|
-
import { validateBboxWithFallback, extractPositionsFromGeometry, geoJsonPositionSchema, validateFeatureCollection, EMPTY_FEATURE_COLLECTION, validateBbox, projectPolygonalToWebMercator, geoJsonPolygonDifference, unprojectPolygonalFromWebMercator, distanceToGeoJsonPolygonBoundary, getGeoJsonPolygonIntersection, isFullyContainedInGeoJsonGeometry, isGeoJsonPointInPolygon, isBboxInsideFeatureCollection, extractEdges, computeGeometryCentroid, isPositionInsideRing, edgePixelLength } from '@trackunit/geo-json-utils';
|
|
18
|
+
import { lngLatToMercatorPxWS, validateBboxWithFallback, extractPositionsFromGeometry, geoJsonPositionSchema, validateFeatureCollection, EMPTY_FEATURE_COLLECTION, validateBbox, projectPolygonalToWebMercator, geoJsonPolygonDifference, unprojectPolygonalFromWebMercator, distanceToGeoJsonPolygonBoundary, getGeoJsonPolygonIntersection, isFullyContainedInGeoJsonGeometry, isGeoJsonPointInPolygon, isBboxInsideFeatureCollection, extractEdges, computeGeometryCentroid, mercatorPxToLngLatWS, isPositionInsideRing, lngLatToWebMercatorPx, edgePixelLength } from '@trackunit/geo-json-utils';
|
|
19
19
|
import { darkenColor, lightenColor } from '@trackunit/react-map-color-utils';
|
|
20
20
|
|
|
21
21
|
var defaultTranslations = {
|
|
@@ -3854,9 +3854,9 @@ const resolveMarkerDomSize = (size, direction, form) => {
|
|
|
3854
3854
|
* both states. The inner indicator disc (`cvaMarkerIndicator` below) carries
|
|
3855
3855
|
* its own per-size `h-* w-*`; the outer surface sizes intrinsically around it.
|
|
3856
3856
|
*
|
|
3857
|
-
* `
|
|
3858
|
-
*
|
|
3859
|
-
*
|
|
3857
|
+
* `transitionProperty` is set inline in `MapMarker.tsx` to list only the
|
|
3858
|
+
* properties that need to animate, intentionally excluding `width` to prevent
|
|
3859
|
+
* non-composited layout thrashing. See `MarkerAnimatedSurface.tsx` for details.
|
|
3860
3860
|
*/
|
|
3861
3861
|
const cvaMapMarker = cvaMerge([
|
|
3862
3862
|
"inline-flex",
|
|
@@ -3865,7 +3865,6 @@ const cvaMapMarker = cvaMerge([
|
|
|
3865
3865
|
"overflow-hidden",
|
|
3866
3866
|
"select-none",
|
|
3867
3867
|
"cursor-pointer",
|
|
3868
|
-
"transition-all",
|
|
3869
3868
|
"rounded-full",
|
|
3870
3869
|
"outline-none",
|
|
3871
3870
|
"focus-visible:ring-2",
|
|
@@ -3936,69 +3935,91 @@ const MarkerDiscContent = ({ icon, iconPx, isPill, dotPx, directionDisplay, }) =
|
|
|
3936
3935
|
return null;
|
|
3937
3936
|
};
|
|
3938
3937
|
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3938
|
+
/**
|
|
3939
|
+
* Compositable per-slot transition — `transform` and `opacity` are GPU-composited
|
|
3940
|
+
* and do not trigger layout (reflow).
|
|
3941
|
+
*
|
|
3942
|
+
* `width` was intentionally omitted: animating `width` is a non-composited operation
|
|
3943
|
+
* that forces the browser to re-run layout on every animation frame. When many markers
|
|
3944
|
+
* transition simultaneously (e.g. after a zoom-driven refetch) this caused ~29 concurrent
|
|
3945
|
+
* non-composited width animations and a CLS score of 0.58. Space-collapse is now handled
|
|
3946
|
+
* via `grid-template-columns: 0fr ↔ 1fr` on the slot wrapper divs, which produces the
|
|
3947
|
+
* same visual result without blocking the compositor.
|
|
3948
|
+
*/
|
|
3949
|
+
const slotContentTransition = (duration, easing) => `transform ${duration}ms ${easing}, opacity ${duration}ms ${easing}`;
|
|
3947
3950
|
const MarkerAnimatedSurface = ({ colors, directionDisplay, duration, effectiveSize, icon, iconPx, isPill, labelText, showDisc, textPx, theme, }) => {
|
|
3948
|
-
const circleD = MARKER_SIZE_MAP[effectiveSize].circle;
|
|
3949
3951
|
const dotPx = MARKER_SIZE_MAP[effectiveSize].dot;
|
|
3950
3952
|
const easing = MARKER_TUNING.animation.morphEasing;
|
|
3951
|
-
const
|
|
3953
|
+
const contentTx = slotContentTransition(duration, easing);
|
|
3952
3954
|
const pillDirectionVisible = isPill && directionDisplay.show;
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3955
|
+
// grid-template-columns 0fr ↔ 1fr is the compositable-friendly space-collapse
|
|
3956
|
+
// technique: the column animates its available-space fraction while overflow:clip
|
|
3957
|
+
// hides the partially-visible content. This avoids animating `width` directly.
|
|
3958
|
+
const gridTx = `grid-template-columns ${duration}ms ${easing}`;
|
|
3959
|
+
return (jsxs(Fragment, { children: [jsx("div", { "data-testid": "MapMarker-disc", style: {
|
|
3960
|
+
display: "grid",
|
|
3956
3961
|
flexShrink: 0,
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
}, children: jsx("span", {
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3962
|
+
gridTemplateColumns: showDisc ? "1fr" : "0fr",
|
|
3963
|
+
overflow: "clip",
|
|
3964
|
+
transition: gridTx,
|
|
3965
|
+
}, children: jsx("span", { style: {
|
|
3966
|
+
alignItems: "center",
|
|
3967
|
+
display: "inline-flex",
|
|
3968
|
+
justifyContent: "center",
|
|
3969
|
+
// Override the default `min-width: auto` on grid items so the `0fr`
|
|
3970
|
+
// track can collapse to zero width instead of the child's min-content.
|
|
3971
|
+
minWidth: 0,
|
|
3972
|
+
}, children: jsx("span", { className: cvaMarkerIndicator({ size: effectiveSize, theme }), style: {
|
|
3973
|
+
flexShrink: 0,
|
|
3974
|
+
opacity: showDisc ? 1 : 0,
|
|
3975
|
+
transform: showDisc ? "scale(1)" : "scale(0)",
|
|
3976
|
+
transition: contentTx,
|
|
3977
|
+
}, children: jsx(MarkerDiscContent, { directionDisplay: directionDisplay, dotPx: dotPx, icon: icon, iconPx: iconPx, isPill: isPill }) }) }) }), jsx("div", { style: {
|
|
3966
3978
|
display: "grid",
|
|
3967
3979
|
gridTemplateColumns: isPill ? "1fr" : "0fr",
|
|
3968
3980
|
overflowX: "clip",
|
|
3969
|
-
transition:
|
|
3981
|
+
transition: gridTx,
|
|
3970
3982
|
}, children: jsx("span", { style: {
|
|
3971
3983
|
alignItems: "center",
|
|
3972
3984
|
display: "flex",
|
|
3985
|
+
// Override the default `min-width: auto` on grid items so the `0fr`
|
|
3986
|
+
// track can collapse to zero width instead of the child's min-content.
|
|
3987
|
+
minWidth: 0,
|
|
3973
3988
|
overflow: "hidden",
|
|
3974
3989
|
}, children: labelText !== undefined ? (jsx("span", { className: cvaPillLabel(), style: {
|
|
3975
3990
|
fontSize: textPx > 0 ? `${textPx}px` : undefined,
|
|
3976
3991
|
maxWidth: MARKER_TUNING.pill.maxLabelWidthPx,
|
|
3977
3992
|
opacity: isPill ? 1 : 0,
|
|
3978
3993
|
transition: `opacity ${duration}ms ${easing}`,
|
|
3979
|
-
}, children: labelText })) : null }) }), jsx("
|
|
3980
|
-
|
|
3981
|
-
display: "inline-flex",
|
|
3994
|
+
}, children: labelText })) : null }) }), jsx("div", { style: {
|
|
3995
|
+
display: "grid",
|
|
3982
3996
|
flexShrink: 0,
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3997
|
+
gridTemplateColumns: isPill ? "1fr" : "0fr",
|
|
3998
|
+
overflow: "clip",
|
|
3999
|
+
transition: gridTx,
|
|
3986
4000
|
}, children: jsx("span", { style: {
|
|
3987
4001
|
alignItems: "center",
|
|
3988
4002
|
display: "inline-flex",
|
|
3989
|
-
flexShrink: 0,
|
|
3990
4003
|
justifyContent: "center",
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
4004
|
+
// Override the default `min-width: auto` on grid items so the `0fr`
|
|
4005
|
+
// track can collapse to zero width instead of the child's min-content.
|
|
4006
|
+
minWidth: 0,
|
|
4007
|
+
}, children: jsx("span", { style: {
|
|
4008
|
+
alignItems: "center",
|
|
4009
|
+
display: "inline-flex",
|
|
3997
4010
|
flexShrink: 0,
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4011
|
+
justifyContent: "center",
|
|
4012
|
+
opacity: pillDirectionVisible ? 1 : 0,
|
|
4013
|
+
transform: pillDirectionVisible ? "scale(1)" : "scale(0)",
|
|
4014
|
+
transformOrigin: "center center",
|
|
4015
|
+
transition: contentTx,
|
|
4016
|
+
}, children: directionDisplay.show ? (jsx(Icon, { ariaHidden: true, "data-testid": "MapMarker-direction-pill", name: "GpsArrowNorth", size: "small", style: {
|
|
4017
|
+
color: colors.textColor,
|
|
4018
|
+
flexShrink: 0,
|
|
4019
|
+
height: directionDisplay.pixelSize,
|
|
4020
|
+
rotate: `${directionDisplay.rotationDegrees}deg`,
|
|
4021
|
+
width: directionDisplay.pixelSize,
|
|
4022
|
+
} })) : null }) }) })] }));
|
|
4002
4023
|
};
|
|
4003
4024
|
|
|
4004
4025
|
const isActivatingKey$2 = (key) => key === "Enter" || key === " ";
|
|
@@ -4138,6 +4159,9 @@ const STICK_FAN_RADIUS_PX = 56;
|
|
|
4138
4159
|
/** Doughnut ring thickness as a percentage of the chart radius (matches the legacy cluster ring). */
|
|
4139
4160
|
const PIE_LINE_WIDTH_PERCENT = 25;
|
|
4140
4161
|
const PIE_START_ANGLE = -90;
|
|
4162
|
+
/** Stable empty sticks array — used as the default for the `sticks` prop so the useEffect
|
|
4163
|
+
* dependency does not change on every render when no sticks are passed. */
|
|
4164
|
+
const EMPTY_STICKS = [];
|
|
4141
4165
|
const isActivatingKey$1 = (key) => key === "Enter" || key === " ";
|
|
4142
4166
|
/** Fan angle (radians) for a given index, starting at top (-π/2) and spread around a full circle. */
|
|
4143
4167
|
const computeFanAngle = (index, total) => {
|
|
@@ -4160,7 +4184,7 @@ const resolveBubbleBackground = (state, config) => {
|
|
|
4160
4184
|
return config.expandedBackground;
|
|
4161
4185
|
};
|
|
4162
4186
|
const ClusterMarkerInner = forwardRef(function ClusterMarkerComponent(props, ref) {
|
|
4163
|
-
const { count, segments, sticks =
|
|
4187
|
+
const { count, segments, sticks = EMPTY_STICKS, onStickClick, onClick, onKeyDown, onMouseEnter, onMouseLeave, onFocus, onBlur, state = "default", theme, colorConfig, className, style, "data-testid": dataTestId, "aria-label": ariaLabel, } = props;
|
|
4164
4188
|
const formatted = formatClusterCount(count);
|
|
4165
4189
|
const effectiveColorConfig = { ...defaultMarkerColorConfig(theme), ...colorConfig };
|
|
4166
4190
|
const colors = resolveMarkerColors("transparent", state, theme, colorConfig);
|
|
@@ -4217,11 +4241,11 @@ const ClusterMarkerInner = forwardRef(function ClusterMarkerComponent(props, ref
|
|
|
4217
4241
|
event.currentTarget.click();
|
|
4218
4242
|
}
|
|
4219
4243
|
}, [onKeyDown]);
|
|
4220
|
-
const pieData = segments.map((segment, index) => ({
|
|
4244
|
+
const pieData = useMemo(() => segments.map((segment, index) => ({
|
|
4221
4245
|
color: segment.color,
|
|
4222
4246
|
value: segment.weight,
|
|
4223
4247
|
title: `segment-${index}`,
|
|
4224
|
-
}));
|
|
4248
|
+
})), [segments]);
|
|
4225
4249
|
const bubbleTestId = dataTestId !== undefined ? `${dataTestId}-bubble` : undefined;
|
|
4226
4250
|
return (jsxs("div", { className: className, "data-testid": dataTestId, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, ref: ref, style: {
|
|
4227
4251
|
position: "relative",
|
|
@@ -4386,6 +4410,9 @@ const MapMarkerInner = forwardRef(function MapMarkerComponent(props, ref) {
|
|
|
4386
4410
|
gap: isPill ? MARKER_TUNING.pill.gapPx : 0,
|
|
4387
4411
|
borderWidth: showPillBorder ? 1 : 0,
|
|
4388
4412
|
borderStyle: "solid",
|
|
4413
|
+
// Explicitly list only the properties that need to animate on the outer shell.
|
|
4414
|
+
// `width` is intentionally excluded — see MarkerAnimatedSurface for details.
|
|
4415
|
+
transitionProperty: "background-color, border-color, border-width, padding, gap, color",
|
|
4389
4416
|
transitionDuration: `${morphDurationMs}ms`,
|
|
4390
4417
|
transitionTimingFunction: MARKER_TUNING.animation.morphEasing,
|
|
4391
4418
|
...(isPill
|
|
@@ -4442,6 +4469,122 @@ function MapMarkerIcon({ name, size, title }) {
|
|
|
4442
4469
|
}, title: title, children: jsx(Icon, { ariaHidden: true, name: name, size: "small" }) }));
|
|
4443
4470
|
}
|
|
4444
4471
|
|
|
4472
|
+
const EMPTY_SET = new Set();
|
|
4473
|
+
/**
|
|
4474
|
+
* Order-sensitive equality. The returned Set keeps a stable reference only when
|
|
4475
|
+
* both membership AND nearest-first ordering are identical. A nearest-first swap
|
|
4476
|
+
* within the same id set produces a new reference so consumers that cap to the
|
|
4477
|
+
* N closest via iteration order see the updated ranking.
|
|
4478
|
+
*/
|
|
4479
|
+
const sameNearby = (a, b) => {
|
|
4480
|
+
if (a === b)
|
|
4481
|
+
return true;
|
|
4482
|
+
if (a.size !== b.size)
|
|
4483
|
+
return false;
|
|
4484
|
+
const ai = a.values();
|
|
4485
|
+
const bi = b.values();
|
|
4486
|
+
for (let i = 0; i < a.size; i++) {
|
|
4487
|
+
if (ai.next().value !== bi.next().value)
|
|
4488
|
+
return false;
|
|
4489
|
+
}
|
|
4490
|
+
return true;
|
|
4491
|
+
};
|
|
4492
|
+
const computeNearby = (cursor, entities, zoom, tileSize, radiusPx) => {
|
|
4493
|
+
if (entities.length === 0)
|
|
4494
|
+
return EMPTY_SET;
|
|
4495
|
+
// Project once per recompute: worldSize is constant for all entities at this
|
|
4496
|
+
// camera, so hoist Math.pow(2, zoom) out of the per-entity loop.
|
|
4497
|
+
const worldSize = tileSize * Math.pow(2, zoom);
|
|
4498
|
+
const [cursorPx, cursorPy] = lngLatToMercatorPxWS(cursor[0], cursor[1], worldSize);
|
|
4499
|
+
const radiusSq = radiusPx * radiusPx;
|
|
4500
|
+
const hits = [];
|
|
4501
|
+
for (const entity of entities) {
|
|
4502
|
+
const [px, py] = lngLatToMercatorPxWS(entity.position[0], entity.position[1], worldSize);
|
|
4503
|
+
const dx = px - cursorPx;
|
|
4504
|
+
const dy = py - cursorPy;
|
|
4505
|
+
// Shortest-path x-distance across the antimeridian: a cursor at 179.99° and
|
|
4506
|
+
// an entity at −179.99° are ~0.02° apart on screen but raw Mercator dx is
|
|
4507
|
+
// nearly worldSize. Taking min(|dx|, worldSize−|dx|) collapses that gap.
|
|
4508
|
+
const absDx = Math.abs(dx);
|
|
4509
|
+
const wrappedDx = Math.min(absDx, worldSize - absDx);
|
|
4510
|
+
const distSq = wrappedDx * wrappedDx + dy * dy;
|
|
4511
|
+
if (distSq <= radiusSq)
|
|
4512
|
+
hits.push({ id: entity.id, distSq });
|
|
4513
|
+
}
|
|
4514
|
+
if (hits.length === 0)
|
|
4515
|
+
return EMPTY_SET;
|
|
4516
|
+
// Nearest-first so a consumer can cap to the N closest by iteration order.
|
|
4517
|
+
hits.sort((a, b) => a.distSq - b.distSq);
|
|
4518
|
+
return new Set(hits.map(hit => hit.id));
|
|
4519
|
+
};
|
|
4520
|
+
/**
|
|
4521
|
+
* Reference/value equality for the recompute inputs. `entities` is compared by
|
|
4522
|
+
* reference (the caller memoises it), keeping the per-render change check O(1)
|
|
4523
|
+
* rather than deep-comparing the whole marker array on every frame.
|
|
4524
|
+
*/
|
|
4525
|
+
const sameInputs = (a, b) => a.entities === b.entities && a.zoom === b.zoom && a.tileSize === b.tileSize && a.radiusPx === b.radiusPx;
|
|
4526
|
+
/**
|
|
4527
|
+
* The **Entities Near Cursor** primitive: returns a referentially-stable
|
|
4528
|
+
* `ReadonlySet<string>` of entity ids whose projected position is within
|
|
4529
|
+
* `radiusPx` CSS pixels of the projected cursor, nearest-first.
|
|
4530
|
+
*
|
|
4531
|
+
* It is the point-marker counterpart to **Shapes Under Cursor** and runs on the
|
|
4532
|
+
* same pure Web Mercator substrate (`@trackunit/geo-json-utils`) fed by
|
|
4533
|
+
* `useCameraState` + the RAF-throttled `pointermove` event — adapter-agnostic by
|
|
4534
|
+
* construction (see ADR-0025). The hook owns radius geometry only; consumers
|
|
4535
|
+
* decide why the ids are wanted (preload, highlight, …) and may cap the set to
|
|
4536
|
+
* the nearest N via iteration order.
|
|
4537
|
+
*
|
|
4538
|
+
* The returned Set keeps a stable identity until either its membership or its
|
|
4539
|
+
* nearest-first ordering changes, so wiring it straight into a memo or query
|
|
4540
|
+
* does not churn while the cursor drifts within the same cluster of dots at the
|
|
4541
|
+
* same relative distances. The host only re-renders when membership or ordering
|
|
4542
|
+
* actually changes: the cursor lives in a ref and recomputes commit through an
|
|
4543
|
+
* order-sensitive functional update that bails out (returns the previous Set)
|
|
4544
|
+
* when nothing changed.
|
|
4545
|
+
*/
|
|
4546
|
+
const useEntitiesNearCursor = (api, options) => {
|
|
4547
|
+
const { entities, radiusPx } = options;
|
|
4548
|
+
const { zoom } = useCameraState(api);
|
|
4549
|
+
const { tileSize } = api.state;
|
|
4550
|
+
const [nearby, setNearby] = useState(EMPTY_SET);
|
|
4551
|
+
// Latest cursor position and recompute inputs, read by the stable subscription
|
|
4552
|
+
// and recompute without re-subscribing. Written only in effects / event
|
|
4553
|
+
// handlers — never during render.
|
|
4554
|
+
const cursorRef = useRef(null);
|
|
4555
|
+
const inputsRef = useRef({ entities, zoom, tileSize, radiusPx });
|
|
4556
|
+
const recompute = useCallback(() => {
|
|
4557
|
+
const cursor = cursorRef.current;
|
|
4558
|
+
const current = inputsRef.current;
|
|
4559
|
+
const next = cursor === null
|
|
4560
|
+
? EMPTY_SET
|
|
4561
|
+
: computeNearby(cursor, current.entities, current.zoom, current.tileSize, current.radiusPx);
|
|
4562
|
+
// Membership-gated functional update: return the previous reference when the
|
|
4563
|
+
// id set is unchanged so React bails out of the re-render and the output
|
|
4564
|
+
// identity stays stable across cursor drift within the same cluster.
|
|
4565
|
+
setNearby(prev => (sameNearby(prev, next) ? prev : next));
|
|
4566
|
+
}, []);
|
|
4567
|
+
// Keep the recompute inputs fresh and recompute when the camera, entities, or
|
|
4568
|
+
// radius change while the cursor stays put (e.g. zooming under a stationary
|
|
4569
|
+
// pointer brings new dots into radius). `useWatch` owns the effect, so this
|
|
4570
|
+
// file never calls setState synchronously inside its own effect.
|
|
4571
|
+
useWatch({
|
|
4572
|
+
value: { entities, zoom, tileSize, radiusPx },
|
|
4573
|
+
immediate: true,
|
|
4574
|
+
isEqual: sameInputs,
|
|
4575
|
+
onChange: latest => {
|
|
4576
|
+
inputsRef.current = latest;
|
|
4577
|
+
recompute();
|
|
4578
|
+
},
|
|
4579
|
+
});
|
|
4580
|
+
// Track the cursor and recompute on each throttled move.
|
|
4581
|
+
useEffect(() => api.on("pointermove", event => {
|
|
4582
|
+
cursorRef.current = event.position;
|
|
4583
|
+
recompute();
|
|
4584
|
+
}), [api, recompute]);
|
|
4585
|
+
return nearby;
|
|
4586
|
+
};
|
|
4587
|
+
|
|
4445
4588
|
const DEFAULT_DEBOUNCE_MS = 150;
|
|
4446
4589
|
/**
|
|
4447
4590
|
* Fires `onShouldPreload` for the currently hovered entity after a debounce
|
|
@@ -7597,7 +7740,7 @@ const computePromotionGroupFills = (members, winnerId, restingPeerFills = new Ma
|
|
|
7597
7740
|
return result;
|
|
7598
7741
|
};
|
|
7599
7742
|
const computeFillTiling = (input) => {
|
|
7600
|
-
const { features, viewportBounds, resolveStackOrder,
|
|
7743
|
+
const { features, viewportBounds, resolveStackOrder, selectedFeatureId, suppressedFeatureIds, layerGeodesic, featureStyles, } = input;
|
|
7601
7744
|
// Densify before any polygon/boundary math so clip geometry follows great-circle
|
|
7602
7745
|
// arcs on large polygons (mirrors the ADR-0024 precedent for edge labels).
|
|
7603
7746
|
const featureCollection = {
|
|
@@ -7636,7 +7779,7 @@ const computeFillTiling = (input) => {
|
|
|
7636
7779
|
featureToGroupKey.set(record.id, key);
|
|
7637
7780
|
}
|
|
7638
7781
|
// 1. Resting order: containment then smaller-area.
|
|
7639
|
-
let order = resolveStackOrder(contended
|
|
7782
|
+
let order = resolveStackOrder(contended);
|
|
7640
7783
|
// 2. Selection override: selected feature always takes front (highest priority).
|
|
7641
7784
|
if (selectedFeatureId !== null && selectedFeatureId !== undefined) {
|
|
7642
7785
|
order = promoteToFront(order, selectedFeatureId);
|
|
@@ -7742,8 +7885,11 @@ const useViewportContext = (api) => {
|
|
|
7742
7885
|
|
|
7743
7886
|
const FALLBACK_CHAR_WIDTH = 6;
|
|
7744
7887
|
const FALLBACK_PADDING = 16;
|
|
7888
|
+
// px-2 from cvaShapeLabel: 8px left + 8px right = 16px total
|
|
7889
|
+
const LABEL_HORIZONTAL_PADDING_PX = 16;
|
|
7745
7890
|
const labelWidthCache = new Map();
|
|
7746
7891
|
let probeElement = null;
|
|
7892
|
+
let canvasCtx = null;
|
|
7747
7893
|
/**
|
|
7748
7894
|
* Character-count fallback for environments where DOM measurement is unavailable
|
|
7749
7895
|
* (SSR, jsdom, headless tests).
|
|
@@ -7770,30 +7916,67 @@ const getProbeElement = () => {
|
|
|
7770
7916
|
return el;
|
|
7771
7917
|
};
|
|
7772
7918
|
/**
|
|
7773
|
-
*
|
|
7774
|
-
*
|
|
7919
|
+
* Returns a CanvasRenderingContext2D configured with the same font as ShapeLabelPill.
|
|
7920
|
+
* The font is read once from the probe element's computed style so canvas measurements
|
|
7921
|
+
* match the actual rendered text width. Returns null when canvas is unavailable.
|
|
7775
7922
|
*
|
|
7776
|
-
*
|
|
7923
|
+
* Canvas.measureText does not trigger a forced layout (reflow), unlike getBoundingClientRect.
|
|
7924
|
+
*/
|
|
7925
|
+
const getCanvasCtx = (probe) => {
|
|
7926
|
+
if (canvasCtx !== null)
|
|
7927
|
+
return canvasCtx;
|
|
7928
|
+
if (typeof document === "undefined")
|
|
7929
|
+
return null;
|
|
7930
|
+
const canvas = document.createElement("canvas");
|
|
7931
|
+
const ctx = canvas.getContext("2d");
|
|
7932
|
+
if (ctx === null)
|
|
7933
|
+
return null;
|
|
7934
|
+
// Read the computed font from the probe element once. getComputedStyle forces
|
|
7935
|
+
// a style recalculation (cheap) but NOT a full layout pass (no reflow).
|
|
7936
|
+
const computed = window.getComputedStyle(probe);
|
|
7937
|
+
// `font` shorthand: "font-style font-variant font-weight font-size/line-height font-family"
|
|
7938
|
+
// Falls back to a safe approximation matching text-xs (12px) + font-medium (500).
|
|
7939
|
+
const font = computed.font || "500 12px ui-sans-serif, system-ui, sans-serif";
|
|
7940
|
+
ctx.font = font;
|
|
7941
|
+
canvasCtx = ctx;
|
|
7942
|
+
return ctx;
|
|
7943
|
+
};
|
|
7944
|
+
/**
|
|
7945
|
+
* Measure the rendered pixel width of label text using a Canvas context configured
|
|
7946
|
+
* with the same font as shape edge labels (`cvaShapeLabel` / `ShapeLabelPill`).
|
|
7947
|
+
*
|
|
7948
|
+
* Results are cached per label text. Using Canvas.measureText avoids the forced
|
|
7949
|
+
* synchronous layout (reflow) that getBoundingClientRect triggers when called inside
|
|
7950
|
+
* a Google Maps onDraw callback — the previous implementation caused ~67ms of blocked
|
|
7951
|
+
* main-thread time per draw cycle during zoom (observed in Chrome DevTools trace).
|
|
7777
7952
|
*
|
|
7778
|
-
*
|
|
7779
|
-
*
|
|
7780
|
-
* estimate (label.length * 6 + 16).
|
|
7953
|
+
* Falls back to DOM measurement if canvas is unavailable, and to a character-count
|
|
7954
|
+
* estimate in environments without DOM (SSR, jsdom).
|
|
7781
7955
|
*/
|
|
7782
7956
|
const measureLabelWidth = (label) => {
|
|
7783
7957
|
const cached = labelWidthCache.get(label);
|
|
7784
7958
|
if (cached !== undefined)
|
|
7785
7959
|
return cached;
|
|
7786
7960
|
const probe = getProbeElement();
|
|
7787
|
-
if (probe
|
|
7788
|
-
const
|
|
7789
|
-
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7961
|
+
if (probe !== null) {
|
|
7962
|
+
const ctx = getCanvasCtx(probe);
|
|
7963
|
+
if (ctx !== null) {
|
|
7964
|
+
const textWidth = ctx.measureText(label).width;
|
|
7965
|
+
const canvasWidth = textWidth + LABEL_HORIZONTAL_PADDING_PX;
|
|
7966
|
+
labelWidthCache.set(label, canvasWidth);
|
|
7967
|
+
return canvasWidth;
|
|
7968
|
+
}
|
|
7969
|
+
// Canvas unavailable — fall back to DOM measurement (triggers reflow, but only
|
|
7970
|
+
// for uncached labels and only when CanvasRenderingContext2D is missing).
|
|
7971
|
+
probe.textContent = label;
|
|
7972
|
+
const measured = probe.getBoundingClientRect().width;
|
|
7973
|
+
const domWidth = measured > 0 ? measured : fallbackLabelWidth(label);
|
|
7974
|
+
labelWidthCache.set(label, domWidth);
|
|
7975
|
+
return domWidth;
|
|
7976
|
+
}
|
|
7977
|
+
const fallback = fallbackLabelWidth(label);
|
|
7978
|
+
labelWidthCache.set(label, fallback);
|
|
7979
|
+
return fallback;
|
|
7797
7980
|
};
|
|
7798
7981
|
|
|
7799
7982
|
const DEG_TO_RAD$1 = Math.PI / 180;
|
|
@@ -7930,14 +8113,13 @@ const isShapeMatch = (entity, handleId, featureKey) => {
|
|
|
7930
8113
|
return shape.handleId === handleId && shape.id === featureKey;
|
|
7931
8114
|
};
|
|
7932
8115
|
/**
|
|
7933
|
-
* Build the per-feature, per-frame context passed to
|
|
7934
|
-
*
|
|
7935
|
-
*
|
|
7936
|
-
*
|
|
8116
|
+
* Build the per-feature, per-frame context passed to viewport-aware shape
|
|
8117
|
+
* callbacks. Pure: no React, no `api` reads — caller supplies the already-
|
|
8118
|
+
* projected viewport bits, the precomputed `shapesInViewport` count for the
|
|
8119
|
+
* layer, a lazy overlap count, and the current interaction state.
|
|
7937
8120
|
*
|
|
7938
8121
|
* Lives next to `shapeLabelResolution.ts` and is consumed by
|
|
7939
|
-
* `useShapeDecorations` once per feature
|
|
7940
|
-
* decoration, before any placement work runs.
|
|
8122
|
+
* `useShapeDecorations` once per feature, before any placement work runs.
|
|
7941
8123
|
*/
|
|
7942
8124
|
const buildShapeLabelResolutionContext = (feature, args) => {
|
|
7943
8125
|
const geometry = feature.geometry;
|
|
@@ -7950,7 +8132,9 @@ const buildShapeLabelResolutionContext = (feature, args) => {
|
|
|
7950
8132
|
return {
|
|
7951
8133
|
zoom: args.zoom,
|
|
7952
8134
|
shapesInViewport: args.shapesInViewport,
|
|
7953
|
-
overlappingShapesCount
|
|
8135
|
+
get overlappingShapesCount() {
|
|
8136
|
+
return args.getOverlappingShapesCount();
|
|
8137
|
+
},
|
|
7954
8138
|
geometryType: geometry.type,
|
|
7955
8139
|
bboxPixelWidth: dims.widthPx,
|
|
7956
8140
|
bboxPixelHeight: dims.heightPx,
|
|
@@ -8042,7 +8226,6 @@ const DEG_TO_RAD = Math.PI / 180;
|
|
|
8042
8226
|
const RAD_TO_DEG$1 = 180 / Math.PI;
|
|
8043
8227
|
const DEFAULT_EDGE_LABEL_INSET_PX = 6;
|
|
8044
8228
|
const LABEL_HEIGHT_PX = 20;
|
|
8045
|
-
const MAX_WEB_MERCATOR_LAT = 85.05112878;
|
|
8046
8229
|
const EARTH_RADIUS_KM = 6371;
|
|
8047
8230
|
const GEODESIC_PLACEMENT_MAX_SEGMENT_RAD = GEODESIC_MAX_SEGMENT_KM / EARTH_RADIUS_KM;
|
|
8048
8231
|
/**
|
|
@@ -8102,20 +8285,6 @@ const clipSegmentToRect = (x0, y0, x1, y1, xMin, yMin, xMax, yMax) => {
|
|
|
8102
8285
|
}
|
|
8103
8286
|
return [x0 + tMin * dx, y0 + tMin * dy, x0 + tMax * dx, y0 + tMax * dy];
|
|
8104
8287
|
};
|
|
8105
|
-
const lngLatToWebMercatorPx = (lng, lat, zoom, tileSize = 256) => {
|
|
8106
|
-
const worldSize = tileSize * Math.pow(2, zoom);
|
|
8107
|
-
const clampedLat = Math.max(-MAX_WEB_MERCATOR_LAT, Math.min(MAX_WEB_MERCATOR_LAT, lat));
|
|
8108
|
-
const x = ((lng + 180) / 360) * worldSize;
|
|
8109
|
-
const latRad = clampedLat * DEG_TO_RAD;
|
|
8110
|
-
const y = (0.5 - Math.log(Math.tan(Math.PI / 4 + latRad / 2)) / (2 * Math.PI)) * worldSize;
|
|
8111
|
-
return [x, y];
|
|
8112
|
-
};
|
|
8113
|
-
const webMercatorPxToLngLat = (px, py, zoom, tileSize = 256) => {
|
|
8114
|
-
const worldSize = tileSize * Math.pow(2, zoom);
|
|
8115
|
-
const lng = (px / worldSize) * 360 - 180;
|
|
8116
|
-
const lat = Math.atan(Math.sinh(Math.PI * (1 - (2 * py) / worldSize))) * RAD_TO_DEG$1;
|
|
8117
|
-
return [lng, lat];
|
|
8118
|
-
};
|
|
8119
8288
|
/**
|
|
8120
8289
|
* Determine which side of an edge the geometry interior lies on, in screen space.
|
|
8121
8290
|
* Returns "above" if the label should extend above the edge (interior is below),
|
|
@@ -8456,6 +8625,8 @@ const findBestEdgePosition = ({ features, viewportBounds, zoom, minPixelWidth, l
|
|
|
8456
8625
|
const [minLon, minLat, maxLon, maxLat] = viewportBounds;
|
|
8457
8626
|
const edges = extractEdges(features);
|
|
8458
8627
|
const centroid = computeGeometryCentroid(features);
|
|
8628
|
+
// Pre-compute once so the projection helpers below don't call Math.pow on every vertex.
|
|
8629
|
+
const worldSize = tileSize * Math.pow(2, zoom);
|
|
8459
8630
|
const candidates = [];
|
|
8460
8631
|
let nextCandidateId = 0;
|
|
8461
8632
|
// Pre-compute pixel viewport bounds so we can clip in pixel space.
|
|
@@ -8464,8 +8635,8 @@ const findBestEdgePosition = ({ features, viewportBounds, zoom, minPixelWidth, l
|
|
|
8464
8635
|
// edge — causing labels to float away from the line at mid-edge positions.
|
|
8465
8636
|
// Clipping in pixel space ensures clip endpoints lie exactly on the
|
|
8466
8637
|
// rendered edge, which fixes the floating at the midpoint of long edges.
|
|
8467
|
-
const [pxViewMin, pyViewMin] =
|
|
8468
|
-
const [pxViewMax, pyViewMax] =
|
|
8638
|
+
const [pxViewMin, pyViewMin] = lngLatToMercatorPxWS(minLon, maxLat, worldSize);
|
|
8639
|
+
const [pxViewMax, pyViewMax] = lngLatToMercatorPxWS(maxLon, minLat, worldSize);
|
|
8469
8640
|
const viewportWidth = pxViewMax - pxViewMin;
|
|
8470
8641
|
const viewportHeight = pyViewMax - pyViewMin;
|
|
8471
8642
|
for (let edgeIdx = 0; edgeIdx < edges.length; edgeIdx++) {
|
|
@@ -8483,8 +8654,8 @@ const findBestEdgePosition = ({ features, viewportBounds, zoom, minPixelWidth, l
|
|
|
8483
8654
|
const segmentClips = [];
|
|
8484
8655
|
for (const segment of getPlacementSegments(edge[0], edge[1], geodesic)) {
|
|
8485
8656
|
const { start, end } = segment;
|
|
8486
|
-
const [startPxX, startPxY] =
|
|
8487
|
-
const [endPxX, endPxY] =
|
|
8657
|
+
const [startPxX, startPxY] = lngLatToMercatorPxWS(start[0], start[1], worldSize);
|
|
8658
|
+
const [endPxX, endPxY] = lngLatToMercatorPxWS(end[0], end[1], worldSize);
|
|
8488
8659
|
const clippedPx = clipSegmentToRect(startPxX, startPxY, endPxX, endPxY, pxViewMin, pyViewMin, pxViewMax, pyViewMax);
|
|
8489
8660
|
if (!clippedPx)
|
|
8490
8661
|
continue;
|
|
@@ -8500,8 +8671,8 @@ const findBestEdgePosition = ({ features, viewportBounds, zoom, minPixelWidth, l
|
|
|
8500
8671
|
: [-rawDx / segPxLen, -rawDy / segPxLen];
|
|
8501
8672
|
// Inverse-project pixel clip endpoints to geo for outward-side and
|
|
8502
8673
|
// polygon-interior checks (qualitative, so approximately correct geo is fine).
|
|
8503
|
-
const [ex0, ey0] =
|
|
8504
|
-
const [ex1, ey1] =
|
|
8674
|
+
const [ex0, ey0] = mercatorPxToLngLatWS(px0, py0, worldSize);
|
|
8675
|
+
const [ex1, ey1] = mercatorPxToLngLatWS(px1, py1, worldSize);
|
|
8505
8676
|
const midLat = (ey0 + ey1) / 2;
|
|
8506
8677
|
const edgeOutwardSide = centroid !== null ? computeOutwardSide(ex0, ey0, ex1, ey1, centroid, midLat) : "above";
|
|
8507
8678
|
if (isLabelInsidePolygon(ex0, ey0, ex1, ey1, features, centroid))
|
|
@@ -8638,7 +8809,7 @@ const findBestEdgePosition = ({ features, viewportBounds, zoom, minPixelWidth, l
|
|
|
8638
8809
|
for (const matchingCandidate of candidates.filter(c => isSameEdge(previousEdgeIdentity, c.edge))) {
|
|
8639
8810
|
if (matchingCandidate.pxLen <= 0)
|
|
8640
8811
|
continue;
|
|
8641
|
-
const [prevAnchorAbsPx, prevAnchorAbsPy] =
|
|
8812
|
+
const [prevAnchorAbsPx, prevAnchorAbsPy] = lngLatToMercatorPxWS(previousAnchorGeo[0], previousAnchorGeo[1], worldSize);
|
|
8642
8813
|
const prevAnchorRelX = prevAnchorAbsPx - pxViewMin;
|
|
8643
8814
|
const prevAnchorRelY = prevAnchorAbsPy - pyViewMin;
|
|
8644
8815
|
const dx = prevAnchorRelX - matchingCandidate.readingStartPx[0];
|
|
@@ -8708,7 +8879,7 @@ const findBestEdgePosition = ({ features, viewportBounds, zoom, minPixelWidth, l
|
|
|
8708
8879
|
// great-circle arc by computing the arc fraction via angular distance
|
|
8709
8880
|
// from A. This places the label physically on the visible curved arc
|
|
8710
8881
|
// rather than on the straight Mercator chord.
|
|
8711
|
-
const [approxLng, approxLat] =
|
|
8882
|
+
const [approxLng, approxLat] = mercatorPxToLngLatWS(anchorRelX + pxViewMin, anchorRelY + pyViewMin, worldSize);
|
|
8712
8883
|
const tArc = Math.max(0, Math.min(1, angularDistance(A[0], A[1], approxLng, approxLat) / delta));
|
|
8713
8884
|
const geoAnchor = intermediatePoint(A, B, tArc, delta);
|
|
8714
8885
|
position = [geoAnchor[0], geoAnchor[1]];
|
|
@@ -8722,13 +8893,13 @@ const findBestEdgePosition = ({ features, viewportBounds, zoom, minPixelWidth, l
|
|
|
8722
8893
|
const centerOffsetFactor = resolvedAnchor === "left" ? 1 : resolvedAnchor === "right" ? -1 : 0;
|
|
8723
8894
|
const centerRelX = anchorRelX + centerOffsetFactor * halfLabelPx * best.directionPx[0];
|
|
8724
8895
|
const centerRelY = anchorRelY + centerOffsetFactor * halfLabelPx * best.directionPx[1];
|
|
8725
|
-
const [approxCenterLng, approxCenterLat] =
|
|
8896
|
+
const [approxCenterLng, approxCenterLat] = mercatorPxToLngLatWS(centerRelX + pxViewMin, centerRelY + pyViewMin, worldSize);
|
|
8726
8897
|
const tArcCenter = Math.max(0, Math.min(1, angularDistance(A[0], A[1], approxCenterLng, approxCenterLat) / delta));
|
|
8727
8898
|
const TANGENT_EPS = 0.001;
|
|
8728
8899
|
const p0 = intermediatePoint(A, B, Math.max(0, tArcCenter - TANGENT_EPS), delta);
|
|
8729
8900
|
const p1 = intermediatePoint(A, B, Math.min(1, tArcCenter + TANGENT_EPS), delta);
|
|
8730
|
-
const [bx, by] =
|
|
8731
|
-
const [ax, ay] =
|
|
8901
|
+
const [bx, by] = lngLatToMercatorPxWS(p0[0], p0[1], worldSize);
|
|
8902
|
+
const [ax, ay] = lngLatToMercatorPxWS(p1[0], p1[1], worldSize);
|
|
8732
8903
|
const ddx = ax - bx;
|
|
8733
8904
|
const ddy = ay - by;
|
|
8734
8905
|
const tangentLen = Math.sqrt(ddx * ddx + ddy * ddy);
|
|
@@ -8745,13 +8916,13 @@ const findBestEdgePosition = ({ features, viewportBounds, zoom, minPixelWidth, l
|
|
|
8745
8916
|
}
|
|
8746
8917
|
else {
|
|
8747
8918
|
// Co-located vertices — fall back to Mercator straight-line.
|
|
8748
|
-
const [anchorLng, anchorLat] =
|
|
8919
|
+
const [anchorLng, anchorLat] = mercatorPxToLngLatWS(anchorRelX + pxViewMin, anchorRelY + pyViewMin, worldSize);
|
|
8749
8920
|
position = [anchorLng, anchorLat];
|
|
8750
8921
|
resolvedDirectionPx = best.directionPx;
|
|
8751
8922
|
}
|
|
8752
8923
|
}
|
|
8753
8924
|
else {
|
|
8754
|
-
const [anchorLng, anchorLat] =
|
|
8925
|
+
const [anchorLng, anchorLat] = mercatorPxToLngLatWS(anchorRelX + pxViewMin, anchorRelY + pyViewMin, worldSize);
|
|
8755
8926
|
position = [anchorLng, anchorLat];
|
|
8756
8927
|
resolvedDirectionPx = best.directionPx;
|
|
8757
8928
|
}
|
|
@@ -9410,26 +9581,23 @@ const useShapeDecorations = ({ onDecorationsChange, onStyleOverridesChange, api,
|
|
|
9410
9581
|
}
|
|
9411
9582
|
return shapesInViewportCache;
|
|
9412
9583
|
};
|
|
9413
|
-
|
|
9584
|
+
// overlappingShapesCount is exposed to viewport-aware callbacks. Keep the
|
|
9585
|
+
// O(n²) overlap computation behind the context property getter so handles
|
|
9586
|
+
// that never read it pay nothing.
|
|
9587
|
+
let overlappingCountsCache = null;
|
|
9588
|
+
const getOverlappingCount = (feature) => {
|
|
9589
|
+
if (overlappingCountsCache === null) {
|
|
9590
|
+
overlappingCountsCache = buildOverlappingShapesCountMap(handle.features.features, featureBboxes, bounds);
|
|
9591
|
+
}
|
|
9592
|
+
return overlappingCountsCache.get(feature) ?? 0;
|
|
9593
|
+
};
|
|
9414
9594
|
handle.features.features.forEach((feature, index) => {
|
|
9415
9595
|
const geometry = feature.geometry;
|
|
9416
9596
|
if (geometry === null || geometry.type === "GeometryCollection")
|
|
9417
9597
|
return;
|
|
9418
9598
|
const featureKey = feature.id !== undefined ? String(feature.id) : String(index);
|
|
9419
|
-
|
|
9420
|
-
|
|
9421
|
-
featureKey,
|
|
9422
|
-
viewportBounds: bounds,
|
|
9423
|
-
zoom,
|
|
9424
|
-
tileSize,
|
|
9425
|
-
shapesInViewport: shapesInViewport(),
|
|
9426
|
-
overlappingShapesCount: overlappingCounts.get(feature) ?? 0,
|
|
9427
|
-
interaction: currentInteraction,
|
|
9428
|
-
});
|
|
9429
|
-
const featureStyle = resolutionContext === null ? handle.resolveStyle(feature) : handle.resolveStyle(feature, resolutionContext);
|
|
9430
|
-
handleStyleOverrides.set(featureKey, featureStyle);
|
|
9431
|
-
const shapeType = geometryTypeToShapeType(geometry.type);
|
|
9432
|
-
const strokeColors = resolveStrokeColors(featureStyle, shapeType, theme);
|
|
9599
|
+
// Partition decorations before building the resolution context so we
|
|
9600
|
+
// can gate the overlap computation on edge-auto presence.
|
|
9433
9601
|
const decorations = handle.getDecorations(feature);
|
|
9434
9602
|
const resolvedStatic = [];
|
|
9435
9603
|
const vertexAutoDecorations = [];
|
|
@@ -9451,6 +9619,20 @@ const useShapeDecorations = ({ onDecorationsChange, onStyleOverridesChange, api,
|
|
|
9451
9619
|
}
|
|
9452
9620
|
}
|
|
9453
9621
|
}
|
|
9622
|
+
const resolutionContext = buildShapeLabelResolutionContext(feature, {
|
|
9623
|
+
handleId: handle.id,
|
|
9624
|
+
featureKey,
|
|
9625
|
+
viewportBounds: bounds,
|
|
9626
|
+
zoom,
|
|
9627
|
+
tileSize,
|
|
9628
|
+
shapesInViewport: shapesInViewport(),
|
|
9629
|
+
getOverlappingShapesCount: () => getOverlappingCount(feature),
|
|
9630
|
+
interaction: currentInteraction,
|
|
9631
|
+
});
|
|
9632
|
+
const featureStyle = resolutionContext === null ? handle.resolveStyle(feature) : handle.resolveStyle(feature, resolutionContext);
|
|
9633
|
+
handleStyleOverrides.set(featureKey, featureStyle);
|
|
9634
|
+
const shapeType = geometryTypeToShapeType(geometry.type);
|
|
9635
|
+
const strokeColors = resolveStrokeColors(featureStyle, shapeType, theme);
|
|
9454
9636
|
const makeEntity = () => ({
|
|
9455
9637
|
type: "shape",
|
|
9456
9638
|
id: featureKey,
|
|
@@ -9744,7 +9926,7 @@ const featureId = (shape) => String(shape.feature.id);
|
|
|
9744
9926
|
* 2. **Smaller area on top** — stable tiebreak; inner shapes are typically
|
|
9745
9927
|
* smaller, so this reinforces containment and keeps nested sites visible.
|
|
9746
9928
|
*/
|
|
9747
|
-
const defaultShapeStackOrder =
|
|
9929
|
+
const defaultShapeStackOrder = contended => {
|
|
9748
9930
|
const idOf = new Map();
|
|
9749
9931
|
for (const shape of contended) {
|
|
9750
9932
|
idOf.set(shape, featureId(shape));
|
|
@@ -10072,7 +10254,6 @@ const useShapeFillTiling = ({ api, handles, onFillGeometriesChange, onZIndexOver
|
|
|
10072
10254
|
}
|
|
10073
10255
|
}, []);
|
|
10074
10256
|
const recompute = useCallback(() => {
|
|
10075
|
-
const currentViewport = viewportRef.current;
|
|
10076
10257
|
const currentHandles = tilingHandlesRef.current;
|
|
10077
10258
|
// Stable suppressed-key: per-handle sorted ids so suppression changes are
|
|
10078
10259
|
// not deduped away by the inputKey guard.
|
|
@@ -10099,12 +10280,13 @@ const useShapeFillTiling = ({ api, handles, onFillGeometriesChange, onZIndexOver
|
|
|
10099
10280
|
return `${handle.id}:${String(layerFlag)}:${featureFlags}`;
|
|
10100
10281
|
})
|
|
10101
10282
|
.join(";");
|
|
10102
|
-
// Bounds are intentionally excluded from the inputKey
|
|
10103
|
-
//
|
|
10104
|
-
//
|
|
10105
|
-
//
|
|
10106
|
-
//
|
|
10107
|
-
|
|
10283
|
+
// Bounds are intentionally excluded from the inputKey: clips use global bounds so
|
|
10284
|
+
// all overlapping features always have pre-computed clips, and polygons entering
|
|
10285
|
+
// the viewport during zoom-out never flash their unclipped fill.
|
|
10286
|
+
// Zoom is intentionally excluded too: fill-tiling stack order is zoom-invariant
|
|
10287
|
+
// by contract, so zooming can reuse the same resting clips and avoid a full
|
|
10288
|
+
// polygon-clipping pass for an identical result.
|
|
10289
|
+
const inputKey = `${tilingContentKeyRef.current}|${selectedFeatureIdRef.current ?? ""}|${suppressedKey}|${geodesicKey}`;
|
|
10108
10290
|
if (inputKey === lastComputeInputKeyRef.current) {
|
|
10109
10291
|
return;
|
|
10110
10292
|
}
|
|
@@ -10132,7 +10314,6 @@ const useShapeFillTiling = ({ api, handles, onFillGeometriesChange, onZIndexOver
|
|
|
10132
10314
|
features: handle.features.features,
|
|
10133
10315
|
viewportBounds: GLOBAL_BOUNDS,
|
|
10134
10316
|
resolveStackOrder: handle.overlap?.resolveStackOrder ?? defaultShapeStackOrder,
|
|
10135
|
-
zoom: currentViewport.zoom,
|
|
10136
10317
|
selectedFeatureId: selectedFeatureIdRef.current,
|
|
10137
10318
|
suppressedFeatureIds: suppressedFillIdsByHandleRef.current?.get(handle.id),
|
|
10138
10319
|
layerGeodesic: handle.style.geodesic,
|
|
@@ -11505,4 +11686,4 @@ const mockMapApi = (overrides) => {
|
|
|
11505
11686
|
*/
|
|
11506
11687
|
setupLibraryTranslations();
|
|
11507
11688
|
|
|
11508
|
-
export { ClusterMarker, ClusterStick, Controls, DEFAULT_MARKER_SIZE_BREAKPOINTS, DefaultControls, Layers, MARKER_DARK_PILL, MARKER_DISC_BORDER_WIDTH_PX, MARKER_LIGHT_PILL, MARKER_PILL_CONTENT_LAYOUT_SIZE, MARKER_SIZE_MAP, MARKER_TUNING, MapLoadingState, MapMarker, MapMarkerIcon, ShapeAnnotationLabel, buildExpandedIds, cvaMapMarker, cvaMarkerIndicator, mockMapApi, useAdaptiveMarkerHelpers, useAutoPanResolver, useCameraIdle, useCameraState, useClusterCountFormat, useControlStack, useControls, useDefaultControls, useDirectionIndicator, useExpandedIds, useFitFeatureBounds, useFitToContent, useImageOverlay, useLayers, useMap, useMapAnnotation, useMapAnnotations, useMapAppearanceControls, useMapKeyboardNavigation, useMarkerColors, useMarkerStateResolvers, useMarkers, usePanel, usePanelPreload, usePreviewMap, useRoute, useShapeLabelHelpers, useShapes, useViewportContext };
|
|
11689
|
+
export { ClusterMarker, ClusterStick, Controls, DEFAULT_MARKER_SIZE_BREAKPOINTS, DefaultControls, Layers, MARKER_DARK_PILL, MARKER_DISC_BORDER_WIDTH_PX, MARKER_LIGHT_PILL, MARKER_PILL_CONTENT_LAYOUT_SIZE, MARKER_SIZE_MAP, MARKER_TUNING, MapLoadingState, MapMarker, MapMarkerIcon, ShapeAnnotationLabel, buildExpandedIds, cvaMapMarker, cvaMarkerIndicator, mockMapApi, useAdaptiveMarkerHelpers, useAutoPanResolver, useCameraIdle, useCameraState, useClusterCountFormat, useControlStack, useControls, useDefaultControls, useDirectionIndicator, useEntitiesNearCursor, useExpandedIds, useFitFeatureBounds, useFitToContent, useImageOverlay, useLayers, useMap, useMapAnnotation, useMapAnnotations, useMapAppearanceControls, useMapKeyboardNavigation, useMarkerColors, useMarkerStateResolvers, useMarkers, usePanel, usePanelPreload, usePreviewMap, useRoute, useShapeLabelHelpers, useShapes, useViewportContext };
|