@trackunit/react-map 0.1.5 → 0.1.6

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 CHANGED
@@ -7404,10 +7404,19 @@ const degreesPerPixel = (zoom, tileSize) => 360 / (tileSize * Math.pow(2, zoom))
7404
7404
  * - Bbox-prefiltered for performance; results are in deterministic (feature-id) order.
7405
7405
  */
7406
7406
  const shapesUnderCursor = (position, features, options) => {
7407
- const { zoom, tileSize, strokeWidthFor, visibleFillFor } = options;
7407
+ const { zoom, tileSize, strokeWidthFor, visibleFillFor, layerGeodesic, featureStyles } = options;
7408
+ // Densify before boundary-distance and point-in-polygon math so stroke/fill
7409
+ // hit-tests follow great-circle arcs on large polygons.
7410
+ const featureCollection = {
7411
+ type: "FeatureCollection",
7412
+ features: Array.from(features),
7413
+ };
7414
+ const densifiedFeatures = layerGeodesic !== false
7415
+ ? reactMapAdapterShared.densifyGeodesicFeatures(featureCollection, layerGeodesic ?? true, featureStyles).features
7416
+ : features;
7408
7417
  const degPerPx = degreesPerPixel(zoom, tileSize);
7409
7418
  const hits = [];
7410
- for (const feature of features) {
7419
+ for (const feature of densifiedFeatures) {
7411
7420
  if (feature.id === undefined)
7412
7421
  continue;
7413
7422
  const geometry = polygonalGeometry(feature);
@@ -7515,9 +7524,17 @@ const promoteToFront = (order, id) => order.includes(id) ? [id, ...order.filter(
7515
7524
  * its full geometry — so peer-to-peer overlap ownership from resting tiling is
7516
7525
  * preserved and translucent fills do not compound under the winner.
7517
7526
  */
7518
- const computePromotionGroupFills = (members, winnerId, restingPeerFills = new Map()) => {
7527
+ const computePromotionGroupFills = (members, winnerId, restingPeerFills = new Map(), layerGeodesic = undefined, featureStyles = undefined) => {
7528
+ // Densify before peer-vs-winner clip so promotion clips follow great-circle arcs.
7529
+ const featureCollection = {
7530
+ type: "FeatureCollection",
7531
+ features: Array.from(members),
7532
+ };
7533
+ const densifiedMembers = layerGeodesic !== false
7534
+ ? reactMapAdapterShared.densifyGeodesicFeatures(featureCollection, layerGeodesic ?? true, featureStyles).features
7535
+ : members;
7519
7536
  const geometries = new Map();
7520
- for (const feature of members) {
7537
+ for (const feature of densifiedMembers) {
7521
7538
  if (feature.id === undefined)
7522
7539
  continue;
7523
7540
  const geometry = polygonalGeometry(feature);
@@ -7553,9 +7570,18 @@ const computePromotionGroupFills = (members, winnerId, restingPeerFills = new Ma
7553
7570
  return result;
7554
7571
  };
7555
7572
  const computeFillTiling = (input) => {
7556
- const { features, viewportBounds, resolveStackOrder, zoom, selectedFeatureId, suppressedFeatureIds } = input;
7573
+ const { features, viewportBounds, resolveStackOrder, zoom, selectedFeatureId, suppressedFeatureIds, layerGeodesic, featureStyles, } = input;
7574
+ // Densify before any polygon/boundary math so clip geometry follows great-circle
7575
+ // arcs on large polygons (mirrors the ADR-0024 precedent for edge labels).
7576
+ const featureCollection = {
7577
+ type: "FeatureCollection",
7578
+ features: Array.from(features),
7579
+ };
7580
+ const densifiedFeatures = layerGeodesic !== false
7581
+ ? reactMapAdapterShared.densifyGeodesicFeatures(featureCollection, layerGeodesic ?? true, featureStyles).features
7582
+ : features;
7557
7583
  const records = [];
7558
- for (const feature of features) {
7584
+ for (const feature of densifiedFeatures) {
7559
7585
  if (feature.id === undefined)
7560
7586
  continue;
7561
7587
  const id = String(feature.id);
@@ -7990,6 +8016,8 @@ const RAD_TO_DEG$1 = 180 / Math.PI;
7990
8016
  const DEFAULT_EDGE_LABEL_INSET_PX = 6;
7991
8017
  const LABEL_HEIGHT_PX = 20;
7992
8018
  const MAX_WEB_MERCATOR_LAT = 85.05112878;
8019
+ const EARTH_RADIUS_KM = 6371;
8020
+ const GEODESIC_PLACEMENT_MAX_SEGMENT_RAD = reactMapAdapterShared.GEODESIC_MAX_SEGMENT_KM / EARTH_RADIUS_KM;
7993
8021
  /**
7994
8022
  * Hysteresis override thresholds.
7995
8023
  *
@@ -8250,6 +8278,29 @@ const computeLabelBoundingBox = (anchorX, anchorY, cosT, sinT, labelAnchor, labe
8250
8278
  }
8251
8279
  return { minX, maxX, minY, maxY };
8252
8280
  };
8281
+ const getPlacementSegments = (start, end, geodesic) => {
8282
+ if (!geodesic) {
8283
+ return [{ start, end, isOriginalStart: true, isOriginalEnd: true }];
8284
+ }
8285
+ const delta = reactMapAdapterShared.angularDistance(start[0], start[1], end[0], end[1]);
8286
+ if (delta === 0) {
8287
+ return [{ start, end, isOriginalStart: true, isOriginalEnd: true }];
8288
+ }
8289
+ const segmentCount = Math.max(1, Math.ceil(delta / GEODESIC_PLACEMENT_MAX_SEGMENT_RAD));
8290
+ const segments = [];
8291
+ let segmentStart = start;
8292
+ for (let segmentIndex = 1; segmentIndex <= segmentCount; segmentIndex++) {
8293
+ const segmentEnd = segmentIndex === segmentCount ? end : reactMapAdapterShared.intermediatePoint(start, end, segmentIndex / segmentCount, delta);
8294
+ segments.push({
8295
+ start: segmentStart,
8296
+ end: segmentEnd,
8297
+ isOriginalStart: segmentIndex === 1,
8298
+ isOriginalEnd: segmentIndex === segmentCount,
8299
+ });
8300
+ segmentStart = segmentEnd;
8301
+ }
8302
+ return segments;
8303
+ };
8253
8304
  // ============================================================================
8254
8305
  // Default resolver
8255
8306
  // ============================================================================
@@ -8280,7 +8331,15 @@ const defaultEdgeLabelPlacementResolver = (context) => {
8280
8331
  : undefined;
8281
8332
  let best;
8282
8333
  if (previousEdgeIdentity !== undefined) {
8283
- const hysteresisCandidate = pool.find(c => c.labelFits && isSameEdge(previousEdgeIdentity, c.edge));
8334
+ // When a held anchor was projected onto a specific segment-candidate, lock onto
8335
+ // that same segment so the "don't slide back" hold fraction (measured in that
8336
+ // segment's reading frame) is applied to the matching candidate. Falling back to
8337
+ // the first fitting segment of the edge would apply the fraction in the wrong
8338
+ // reading frame, making the label jump back toward the edge start when panning.
8339
+ const heldCandidate = context.previousAnchorClippedCandidateId !== undefined
8340
+ ? pool.find(c => c.candidateId === context.previousAnchorClippedCandidateId && c.labelFits)
8341
+ : undefined;
8342
+ const hysteresisCandidate = heldCandidate ?? pool.find(c => c.labelFits && isSameEdge(previousEdgeIdentity, c.edge));
8284
8343
  if (hysteresisCandidate !== undefined) {
8285
8344
  const isHysteresisCandidateSteep = Math.abs(hysteresisCandidate.angleDeg) > STEEP_EDGE_THRESHOLD_DEG;
8286
8345
  if (isHysteresisCandidateSteep) {
@@ -8339,7 +8398,7 @@ const defaultEdgeLabelPlacementResolver = (context) => {
8339
8398
  // the center of the pill element to that geo position. Together they visually
8340
8399
  // center the label on the edge rather than pinning the left edge at the midpoint.
8341
8400
  if (isForced && !best.labelFits) {
8342
- return { edgeIdx: best.edgeIdx, side, anchorT: 0.5, anchor: "center" };
8401
+ return { edgeIdx: best.edgeIdx, candidateId: best.candidateId, side, anchorT: 0.5, anchor: "center" };
8343
8402
  }
8344
8403
  // "Don't slide back" — for left-anchored labels on the same edge as before,
8345
8404
  // once the viewport has pushed the anchor rightward (to stay in view), keep it
@@ -8357,20 +8416,21 @@ const defaultEdgeLabelPlacementResolver = (context) => {
8357
8416
  const maxSafeT = best.pxLen > 0 ? (best.pxLen - best.endInsetPx - context.labelPixelWidth) / best.pxLen : 0;
8358
8417
  const clampedT = Math.max(defaultLeftT, Math.min(maxSafeT, context.previousAnchorClippedT));
8359
8418
  if (clampedT > defaultLeftT) {
8360
- return { edgeIdx: best.edgeIdx, side, anchorT: clampedT };
8419
+ return { edgeIdx: best.edgeIdx, candidateId: best.candidateId, side, anchorT: clampedT };
8361
8420
  }
8362
8421
  }
8363
8422
  }
8364
- return { edgeIdx: best.edgeIdx, side };
8423
+ return { edgeIdx: best.edgeIdx, candidateId: best.candidateId, side };
8365
8424
  };
8366
8425
  // ============================================================================
8367
8426
  // Main function
8368
8427
  // ============================================================================
8369
- const findBestEdgePosition = ({ features, viewportBounds, zoom, minPixelWidth, labelPixelWidth, tileSize = 256, maxReadableAngleDeg, previousEdgeIdentity, previousAnchorGeo, previousLayoutSide, edgeInsets, labelAnchor = "left", labelPlacementResolver, isForced = false, }) => {
8428
+ const findBestEdgePosition = ({ features, viewportBounds, zoom, minPixelWidth, labelPixelWidth, tileSize = 256, maxReadableAngleDeg, previousEdgeIdentity, previousAnchorGeo, previousLayoutSide, edgeInsets, labelAnchor = "left", labelPlacementResolver, isForced = false, geodesic = false, }) => {
8370
8429
  const [minLon, minLat, maxLon, maxLat] = viewportBounds;
8371
8430
  const edges = geoJsonUtils.extractEdges(features);
8372
8431
  const centroid = geoJsonUtils.computeGeometryCentroid(features);
8373
8432
  const candidates = [];
8433
+ let nextCandidateId = 0;
8374
8434
  // Pre-compute pixel viewport bounds so we can clip in pixel space.
8375
8435
  // Mercator y is non-linear in latitude, so clipping in geo space then
8376
8436
  // projecting gives clip points that are NOT on the rendered (pixel-space)
@@ -8385,75 +8445,159 @@ const findBestEdgePosition = ({ features, viewportBounds, zoom, minPixelWidth, l
8385
8445
  const edge = edges[edgeIdx];
8386
8446
  if (edge === undefined)
8387
8447
  continue;
8388
- const [start, end] = edge;
8389
- // Project both endpoints to pixel space, then clip there.
8390
- const [startPxX, startPxY] = lngLatToWebMercatorPx(start[0], start[1], zoom, tileSize);
8391
- const [endPxX, endPxY] = lngLatToWebMercatorPx(end[0], end[1], zoom, tileSize);
8392
- const clippedPx = clipSegmentToRect(startPxX, startPxY, endPxX, endPxY, pxViewMin, pyViewMin, pxViewMax, pyViewMax);
8393
- if (!clippedPx)
8448
+ const sourceEdge = edge;
8449
+ // Collect every clipped segment for this edge. For geodesic edges there
8450
+ // will be multiple short arc segments; for Mercator there is always one.
8451
+ // After collection we derive a single "chord" candidate that spans from the
8452
+ // reading-start of the first visible segment to the reading-end of the last
8453
+ // visible segment. Using the chord (straight-line) length — not the summed
8454
+ // arc length — ensures fit/visibility checks match what the label actually
8455
+ // occupies in screen space.
8456
+ const segmentClips = [];
8457
+ for (const segment of getPlacementSegments(edge[0], edge[1], geodesic)) {
8458
+ const { start, end } = segment;
8459
+ const [startPxX, startPxY] = lngLatToWebMercatorPx(start[0], start[1], zoom, tileSize);
8460
+ const [endPxX, endPxY] = lngLatToWebMercatorPx(end[0], end[1], zoom, tileSize);
8461
+ const clippedPx = clipSegmentToRect(startPxX, startPxY, endPxX, endPxY, pxViewMin, pyViewMin, pxViewMax, pyViewMax);
8462
+ if (!clippedPx)
8463
+ continue;
8464
+ const [px0, py0, px1, py1] = clippedPx;
8465
+ const rawDx = px1 - px0;
8466
+ const rawDy = py1 - py0;
8467
+ const segPxLen = Math.sqrt(rawDx * rawDx + rawDy * rawDy);
8468
+ if (segPxLen === 0)
8469
+ continue;
8470
+ const readsFromClippedStart = rawDx >= 0;
8471
+ const directionPx = readsFromClippedStart
8472
+ ? [rawDx / segPxLen, rawDy / segPxLen]
8473
+ : [-rawDx / segPxLen, -rawDy / segPxLen];
8474
+ // Inverse-project pixel clip endpoints to geo for outward-side and
8475
+ // polygon-interior checks (qualitative, so approximately correct geo is fine).
8476
+ const [ex0, ey0] = webMercatorPxToLngLat(px0, py0, zoom, tileSize);
8477
+ const [ex1, ey1] = webMercatorPxToLngLat(px1, py1, zoom, tileSize);
8478
+ const midLat = (ey0 + ey1) / 2;
8479
+ const edgeOutwardSide = centroid !== null ? computeOutwardSide(ex0, ey0, ex1, ey1, centroid, midLat) : "above";
8480
+ if (isLabelInsidePolygon(ex0, ey0, ex1, ey1, features, centroid))
8481
+ continue;
8482
+ const inset = edgeInsets?.[edgeIdx];
8483
+ const readingStartInset = readsFromClippedStart && segment.isOriginalStart
8484
+ ? inset?.startPx
8485
+ : !readsFromClippedStart && segment.isOriginalEnd
8486
+ ? inset?.endPx
8487
+ : 0;
8488
+ const readingEndInset = readsFromClippedStart && segment.isOriginalEnd
8489
+ ? inset?.endPx
8490
+ : !readsFromClippedStart && segment.isOriginalStart
8491
+ ? inset?.startPx
8492
+ : 0;
8493
+ const startInsetPx = Math.max(DEFAULT_EDGE_LABEL_INSET_PX, readingStartInset ?? 0);
8494
+ const endInsetPx = Math.max(DEFAULT_EDGE_LABEL_INSET_PX, readingEndInset ?? 0);
8495
+ const readingStartPx = readsFromClippedStart
8496
+ ? [px0 - pxViewMin, py0 - pyViewMin]
8497
+ : [px1 - pxViewMin, py1 - pyViewMin];
8498
+ const readingEndPx = readsFromClippedStart
8499
+ ? [px1 - pxViewMin, py1 - pyViewMin]
8500
+ : [px0 - pxViewMin, py0 - pyViewMin];
8501
+ segmentClips.push({
8502
+ segment,
8503
+ segmentPxLen: segPxLen,
8504
+ readsFromClippedStart,
8505
+ directionPx,
8506
+ readingStartPx,
8507
+ readingEndPx,
8508
+ outwardSide: edgeOutwardSide,
8509
+ startInsetPx,
8510
+ endInsetPx,
8511
+ });
8512
+ }
8513
+ if (segmentClips.length === 0)
8394
8514
  continue;
8395
- const [px0, py0, px1, py1] = clippedPx;
8396
- // Inverse-project pixel clip endpoints to geo for outward-side and
8397
- // polygon-interior checks (qualitative, so approximately correct geo is fine).
8398
- const [ex0, ey0] = webMercatorPxToLngLat(px0, py0, zoom, tileSize);
8399
- const [ex1, ey1] = webMercatorPxToLngLat(px1, py1, zoom, tileSize);
8400
- const midLat = (ey0 + ey1) / 2;
8401
- const rawDx = px1 - px0;
8402
- const rawDy = py1 - py0;
8403
- const pxLen = Math.sqrt(rawDx * rawDx + rawDy * rawDy);
8404
- if (pxLen === 0)
8515
+ // ── Build the chord spanning the full clipped arc ─────────────────────────
8516
+ //
8517
+ // For geodesic edges the label must fit in screen-space. The chord (straight
8518
+ // line from the first visible segment's reading start to the last visible
8519
+ // segment's reading end) is the actual screen-space extent of the arc.
8520
+ // Using chord length instead of the summed arc length prevents the label
8521
+ // from extending past a polygon corner even when the arc is longer than
8522
+ // the chord.
8523
+ //
8524
+ // For a right-to-left edge (readsFromClippedStart = false),
8525
+ // getPlacementSegments returns segments in geographic A→B order but the
8526
+ // reading direction is B→A, so the chord start is the LAST segment's
8527
+ // readingStartPx and the chord end is the FIRST segment's readingEndPx.
8528
+ // segmentClips is non-empty (checked above); TypeScript doesn't narrow that
8529
+ // from .length > 0, so we do a non-null assertion via the bang-free fallback.
8530
+ const firstClip = segmentClips[0];
8531
+ const lastClip = segmentClips[segmentClips.length - 1];
8532
+ if (firstClip === undefined || lastClip === undefined)
8405
8533
  continue;
8406
- const readsFromClippedStart = rawDx >= 0;
8407
- const directionPx = readsFromClippedStart
8408
- ? [rawDx / pxLen, rawDy / pxLen]
8409
- : [-rawDx / pxLen, -rawDy / pxLen];
8410
- const angleDeg = Math.atan2(directionPx[1], directionPx[0]) * RAD_TO_DEG$1;
8411
- if (pxLen < minPixelWidth)
8534
+ const readsFromStart = firstClip.readsFromClippedStart;
8535
+ const chordReadingStartPx = readsFromStart ? firstClip.readingStartPx : lastClip.readingStartPx;
8536
+ const chordReadingEndPx = readsFromStart ? lastClip.readingEndPx : firstClip.readingEndPx;
8537
+ const chordDx = chordReadingEndPx[0] - chordReadingStartPx[0];
8538
+ const chordDy = chordReadingEndPx[1] - chordReadingStartPx[1];
8539
+ const chordPxLen = Math.sqrt(chordDx * chordDx + chordDy * chordDy);
8540
+ if (chordPxLen === 0)
8412
8541
  continue;
8413
- const edgeOutwardSide = centroid !== null ? computeOutwardSide(ex0, ey0, ex1, ey1, centroid, midLat) : "above";
8414
- if (isLabelInsidePolygon(ex0, ey0, ex1, ey1, features, centroid))
8542
+ if (chordPxLen < minPixelWidth)
8415
8543
  continue;
8416
- const inset = edgeInsets?.[edgeIdx];
8417
- const startInsetPx = Math.max(DEFAULT_EDGE_LABEL_INSET_PX, (readsFromClippedStart ? inset?.startPx : inset?.endPx) ?? 0);
8418
- const endInsetPx = Math.max(DEFAULT_EDGE_LABEL_INSET_PX, (readsFromClippedStart ? inset?.endPx : inset?.startPx) ?? 0);
8419
- const availableWidthPx = Math.max(0, pxLen - startInsetPx - endInsetPx);
8420
- const labelFits = availableWidthPx >= labelPixelWidth;
8421
- // Viewport-relative reading start/end (subtract viewport origin so bbox
8422
- // checks can be done against [0, viewportWidth] × [0, viewportHeight]).
8423
- const readingStartPx = readsFromClippedStart
8424
- ? [px0 - pxViewMin, py0 - pyViewMin]
8425
- : [px1 - pxViewMin, py1 - pyViewMin];
8426
- const readingEndPx = readsFromClippedStart
8427
- ? [px1 - pxViewMin, py1 - pyViewMin]
8428
- : [px0 - pxViewMin, py0 - pyViewMin];
8429
- // Compute bbox anchor in viewport-relative coords.
8430
- const anchorOffsetForBbox = labelAnchor === "left"
8431
- ? startInsetPx
8432
- : labelAnchor === "center"
8433
- ? startInsetPx + availableWidthPx / 2
8434
- : pxLen - endInsetPx;
8435
- const anchorTForBbox = pxLen > 0 ? Math.max(0, Math.min(pxLen, anchorOffsetForBbox)) / pxLen : 0;
8436
- const bboxAnchorX = readingStartPx[0] + anchorTForBbox * (readingEndPx[0] - readingStartPx[0]);
8437
- const bboxAnchorY = readingStartPx[1] + anchorTForBbox * (readingEndPx[1] - readingStartPx[1]);
8438
- const outwardBbox = computeLabelBoundingBox(bboxAnchorX, bboxAnchorY, directionPx[0], directionPx[1], labelAnchor, labelPixelWidth, edgeOutwardSide);
8439
- const flippedSide = edgeOutwardSide === "above" ? "below" : "above";
8440
- const inwardBbox = computeLabelBoundingBox(bboxAnchorX, bboxAnchorY, directionPx[0], directionPx[1], labelAnchor, labelPixelWidth, flippedSide);
8441
- candidates.push({
8442
- edgeIdx,
8443
- edge: [start, end],
8444
- pxLen,
8445
- angleDeg,
8446
- availableWidthPx,
8447
- labelFits,
8448
- outwardSide: edgeOutwardSide,
8449
- startInsetPx,
8450
- endInsetPx,
8451
- directionPx,
8452
- readingStartPx,
8453
- readingEndPx,
8454
- outwardBbox,
8455
- inwardBbox,
8456
- });
8544
+ const chordDirectionPx = [chordDx / chordPxLen, chordDy / chordPxLen];
8545
+ const chordAngleDeg = Math.atan2(chordDy, chordDx) * RAD_TO_DEG$1;
8546
+ // Edge insets come from the chord-start and chord-end segment.
8547
+ const chordStartClip = readsFromStart ? firstClip : lastClip;
8548
+ const chordEndClip = readsFromStart ? lastClip : firstClip;
8549
+ const chordStartInsetPx = chordStartClip.startInsetPx;
8550
+ const chordEndInsetPx = chordEndClip.endInsetPx;
8551
+ const chordAvailableWidthPx = Math.max(0, chordPxLen - chordStartInsetPx - chordEndInsetPx);
8552
+ const chordLabelFits = chordAvailableWidthPx >= labelPixelWidth;
8553
+ // ── One candidate per visible segment, but with chord-level properties ──
8554
+ //
8555
+ // The chord properties (pxLen, available width, fit, reading direction,
8556
+ // readingStartPx/EndPx) govern the final anchor position and angle — using
8557
+ // the chord prevents protrusion past polygon corners caused by arc > chord.
8558
+ //
8559
+ // The bbox for each candidate is computed at that segment's own label anchor
8560
+ // position (using the segment's own available width), oriented along the
8561
+ // segment's own direction. This gives per-segment viewport-fit diversity so
8562
+ // narrow viewports where only part of the arc is horizontal enough still
8563
+ // produce at least one pool candidate.
8564
+ for (const clip of segmentClips) {
8565
+ // Per-segment bbox anchor at the segment's own label center / left / right.
8566
+ const segAvailableWidthPx = Math.max(0, clip.segmentPxLen - clip.startInsetPx - clip.endInsetPx);
8567
+ const segAnchorOffsetForBbox = labelAnchor === "left"
8568
+ ? clip.startInsetPx
8569
+ : labelAnchor === "center"
8570
+ ? clip.startInsetPx + segAvailableWidthPx / 2
8571
+ : clip.segmentPxLen - clip.endInsetPx;
8572
+ const segAnchorTForBbox = clip.segmentPxLen > 0
8573
+ ? Math.max(0, Math.min(clip.segmentPxLen, segAnchorOffsetForBbox)) / clip.segmentPxLen
8574
+ : 0;
8575
+ const bboxAnchorX = clip.readingStartPx[0] + segAnchorTForBbox * (clip.readingEndPx[0] - clip.readingStartPx[0]);
8576
+ const bboxAnchorY = clip.readingStartPx[1] + segAnchorTForBbox * (clip.readingEndPx[1] - clip.readingStartPx[1]);
8577
+ const outwardBbox = computeLabelBoundingBox(bboxAnchorX, bboxAnchorY, clip.directionPx[0], clip.directionPx[1], labelAnchor, labelPixelWidth, clip.outwardSide);
8578
+ const flippedSide = clip.outwardSide === "above" ? "below" : "above";
8579
+ const inwardBbox = computeLabelBoundingBox(bboxAnchorX, bboxAnchorY, clip.directionPx[0], clip.directionPx[1], labelAnchor, labelPixelWidth, flippedSide);
8580
+ candidates.push({
8581
+ candidateId: nextCandidateId,
8582
+ edgeIdx,
8583
+ edge: sourceEdge,
8584
+ // Chord-level: anchor, fit, resolver selection criteria
8585
+ pxLen: chordPxLen,
8586
+ angleDeg: chordAngleDeg,
8587
+ availableWidthPx: chordAvailableWidthPx,
8588
+ labelFits: chordLabelFits,
8589
+ startInsetPx: chordStartInsetPx,
8590
+ endInsetPx: chordEndInsetPx,
8591
+ directionPx: chordDirectionPx,
8592
+ readingStartPx: chordReadingStartPx,
8593
+ readingEndPx: chordReadingEndPx,
8594
+ // Per-segment: bbox viewport filtering
8595
+ outwardBbox,
8596
+ inwardBbox,
8597
+ outwardSide: clip.outwardSide,
8598
+ });
8599
+ nextCandidateId++;
8600
+ }
8457
8601
  }
8458
8602
  if (candidates.length === 0) {
8459
8603
  return null;
@@ -8462,9 +8606,11 @@ const findBestEdgePosition = ({ features, viewportBounds, zoom, minPixelWidth, l
8462
8606
  // the reading direction of the matching previous-edge candidate so the resolver
8463
8607
  // can enforce "don't slide back left" without needing raw Mercator math.
8464
8608
  let previousAnchorClippedT;
8609
+ let previousAnchorClippedCandidateId;
8465
8610
  if (previousAnchorGeo !== undefined && previousEdgeIdentity !== undefined) {
8466
- const matchingCandidate = candidates.find(c => isSameEdge(previousEdgeIdentity, c.edge));
8467
- if (matchingCandidate !== undefined && matchingCandidate.pxLen > 0) {
8611
+ for (const matchingCandidate of candidates.filter(c => isSameEdge(previousEdgeIdentity, c.edge))) {
8612
+ if (matchingCandidate.pxLen <= 0)
8613
+ continue;
8468
8614
  const [prevAnchorAbsPx, prevAnchorAbsPy] = lngLatToWebMercatorPx(previousAnchorGeo[0], previousAnchorGeo[1], zoom, tileSize);
8469
8615
  const prevAnchorRelX = prevAnchorAbsPx - pxViewMin;
8470
8616
  const prevAnchorRelY = prevAnchorAbsPy - pyViewMin;
@@ -8477,8 +8623,10 @@ const findBestEdgePosition = ({ features, viewportBounds, zoom, minPixelWidth, l
8477
8623
  // right of the current clip start (t >= 0). A negative t means the viewport has
8478
8624
  // scrolled so far right that the anchor is now behind the left clip boundary —
8479
8625
  // in that case the default left position is already as far right as we can go.
8480
- if (t >= 0) {
8481
- previousAnchorClippedT = Math.min(1, t);
8626
+ if (t >= 0 && t <= 1) {
8627
+ previousAnchorClippedT = t;
8628
+ previousAnchorClippedCandidateId = matchingCandidate.candidateId;
8629
+ break;
8482
8630
  }
8483
8631
  }
8484
8632
  }
@@ -8491,13 +8639,16 @@ const findBestEdgePosition = ({ features, viewportBounds, zoom, minPixelWidth, l
8491
8639
  previousEdgeIdentity,
8492
8640
  isForced,
8493
8641
  previousAnchorClippedT,
8642
+ previousAnchorClippedCandidateId,
8494
8643
  previousLayoutSide,
8495
8644
  };
8496
8645
  const resolver = labelPlacementResolver ?? defaultEdgeLabelPlacementResolver;
8497
8646
  const decision = resolver(context);
8498
8647
  if (decision === null)
8499
8648
  return null;
8500
- const best = candidates.find(c => c.edgeIdx === decision.edgeIdx);
8649
+ const best = decision.candidateId !== undefined
8650
+ ? candidates.find(c => c.candidateId === decision.candidateId)
8651
+ : candidates.find(c => c.edgeIdx === decision.edgeIdx);
8501
8652
  if (best === undefined)
8502
8653
  return null;
8503
8654
  const fitMode = best.labelFits ? "fits" : "clipped";
@@ -8520,12 +8671,68 @@ const findBestEdgePosition = ({ features, viewportBounds, zoom, minPixelWidth, l
8520
8671
  // readingStartPx/readingEndPx are viewport-relative; add back viewport origin for absolute px.
8521
8672
  const anchorRelX = best.readingStartPx[0] + anchorT * (best.readingEndPx[0] - best.readingStartPx[0]);
8522
8673
  const anchorRelY = best.readingStartPx[1] + anchorT * (best.readingEndPx[1] - best.readingStartPx[1]);
8523
- const [anchorLng, anchorLat] = webMercatorPxToLngLat(anchorRelX + pxViewMin, anchorRelY + pyViewMin, zoom, tileSize);
8674
+ let position;
8675
+ let resolvedDirectionPx;
8676
+ if (geodesic) {
8677
+ const [A, B] = best.edge;
8678
+ const delta = reactMapAdapterShared.angularDistance(A[0], A[1], B[0], B[1]);
8679
+ if (delta > 0) {
8680
+ // Project the Mercator anchor pixel back to geo, then map it onto the
8681
+ // great-circle arc by computing the arc fraction via angular distance
8682
+ // from A. This places the label physically on the visible curved arc
8683
+ // rather than on the straight Mercator chord.
8684
+ const [approxLng, approxLat] = webMercatorPxToLngLat(anchorRelX + pxViewMin, anchorRelY + pyViewMin, zoom, tileSize);
8685
+ const tArc = Math.max(0, Math.min(1, reactMapAdapterShared.angularDistance(A[0], A[1], approxLng, approxLat) / delta));
8686
+ const geoAnchor = reactMapAdapterShared.intermediatePoint(A, B, tArc, delta);
8687
+ position = [geoAnchor[0], geoAnchor[1]];
8688
+ // Tangent: finite-difference at the visual center of the label (not the
8689
+ // anchor point). For a "left"-anchored label the anchor sits at the left
8690
+ // edge of the pill; evaluating the tangent there means the label hugs the
8691
+ // arc on the left but drifts on the right on curved edges. Computing the
8692
+ // tangent at the label's midpoint (anchor ± halfWidth along the reading
8693
+ // direction) keeps both sides equally aligned to the curve.
8694
+ const halfLabelPx = labelPixelWidth / 2;
8695
+ const centerOffsetFactor = resolvedAnchor === "left" ? 1 : resolvedAnchor === "right" ? -1 : 0;
8696
+ const centerRelX = anchorRelX + centerOffsetFactor * halfLabelPx * best.directionPx[0];
8697
+ const centerRelY = anchorRelY + centerOffsetFactor * halfLabelPx * best.directionPx[1];
8698
+ const [approxCenterLng, approxCenterLat] = webMercatorPxToLngLat(centerRelX + pxViewMin, centerRelY + pyViewMin, zoom, tileSize);
8699
+ const tArcCenter = Math.max(0, Math.min(1, reactMapAdapterShared.angularDistance(A[0], A[1], approxCenterLng, approxCenterLat) / delta));
8700
+ const TANGENT_EPS = 0.001;
8701
+ const p0 = reactMapAdapterShared.intermediatePoint(A, B, Math.max(0, tArcCenter - TANGENT_EPS), delta);
8702
+ const p1 = reactMapAdapterShared.intermediatePoint(A, B, Math.min(1, tArcCenter + TANGENT_EPS), delta);
8703
+ const [bx, by] = lngLatToWebMercatorPx(p0[0], p0[1], zoom, tileSize);
8704
+ const [ax, ay] = lngLatToWebMercatorPx(p1[0], p1[1], zoom, tileSize);
8705
+ const ddx = ax - bx;
8706
+ const ddy = ay - by;
8707
+ const tangentLen = Math.sqrt(ddx * ddx + ddy * ddy);
8708
+ if (tangentLen > 0) {
8709
+ const rawDir = [ddx / tangentLen, ddy / tangentLen];
8710
+ // Orient tangent to match the reading direction stored in best.directionPx.
8711
+ const dot = best.directionPx[0] * rawDir[0] + best.directionPx[1] * rawDir[1];
8712
+ const negDir = [-rawDir[0], -rawDir[1]];
8713
+ resolvedDirectionPx = dot >= 0 ? rawDir : negDir;
8714
+ }
8715
+ else {
8716
+ resolvedDirectionPx = best.directionPx;
8717
+ }
8718
+ }
8719
+ else {
8720
+ // Co-located vertices — fall back to Mercator straight-line.
8721
+ const [anchorLng, anchorLat] = webMercatorPxToLngLat(anchorRelX + pxViewMin, anchorRelY + pyViewMin, zoom, tileSize);
8722
+ position = [anchorLng, anchorLat];
8723
+ resolvedDirectionPx = best.directionPx;
8724
+ }
8725
+ }
8726
+ else {
8727
+ const [anchorLng, anchorLat] = webMercatorPxToLngLat(anchorRelX + pxViewMin, anchorRelY + pyViewMin, zoom, tileSize);
8728
+ position = [anchorLng, anchorLat];
8729
+ resolvedDirectionPx = best.directionPx;
8730
+ }
8524
8731
  return {
8525
- position: [anchorLng, anchorLat],
8732
+ position,
8526
8733
  layout: {
8527
8734
  type: "edge",
8528
- directionPx: best.directionPx,
8735
+ directionPx: resolvedDirectionPx,
8529
8736
  anchor: resolvedAnchor,
8530
8737
  outwardSide: layoutOutwardSide,
8531
8738
  },
@@ -8581,7 +8788,7 @@ const placementToAnchor = (placement) => {
8581
8788
  * caller-managed annotation).
8582
8789
  */
8583
8790
  const computeEdgeAutoPlacement = (feature, label, viewportBounds, zoom, tileSize, options) => {
8584
- const { labelPixelWidth, mode = "auto", previousAnchorGeo, previousLayoutSide } = options;
8791
+ const { labelPixelWidth, mode = "auto", previousAnchorGeo, previousLayoutSide, geodesic = false } = options;
8585
8792
  const geomType = feature.geometry?.type;
8586
8793
  const isPointGeometry = geomType === "Point" || geomType === "MultiPoint";
8587
8794
  if (isPointGeometry) {
@@ -8623,6 +8830,7 @@ const computeEdgeAutoPlacement = (feature, label, viewportBounds, zoom, tileSize
8623
8830
  edgeInsets: options.edgeInsets,
8624
8831
  labelAnchor: options.labelAnchor,
8625
8832
  labelPlacementResolver: options.labelPlacementResolver,
8833
+ geodesic,
8626
8834
  });
8627
8835
  if (edgePlacement !== null) {
8628
8836
  return {
@@ -8650,6 +8858,7 @@ const computeEdgeAutoPlacement = (feature, label, viewportBounds, zoom, tileSize
8650
8858
  labelAnchor: options.labelAnchor,
8651
8859
  labelPlacementResolver: options.labelPlacementResolver,
8652
8860
  isForced: true,
8861
+ geodesic,
8653
8862
  });
8654
8863
  if (forcedPlacement !== null) {
8655
8864
  const fitMode = forcedPlacement.fitMode === "clipped" ? "overflow" : forcedPlacement.fitMode;
@@ -8688,12 +8897,36 @@ const isLineGeometry = (geometry) => {
8688
8897
  * For Polygons, `outwardSide` uses the cross product with the geometry centroid
8689
8898
  * to determine which side faces away from the interior. For LineStrings (no
8690
8899
  * interior), `outwardSide` defaults to `"above"`.
8900
+ *
8901
+ * When `geodesic` is `true`, `angleDeg` is derived from the arc tangent at
8902
+ * the edge midpoint (t = 0.5) via finite difference, so decorations are
8903
+ * rotated correctly relative to the visible curved edge.
8691
8904
  */
8692
- const computeEdgeProperties = (start, end, geometry, zoom, tileSize) => {
8905
+ const computeEdgeProperties = (start, end, geometry, zoom, tileSize, geodesic = false) => {
8693
8906
  const midLat = (start[1] + end[1]) / 2;
8694
- const [startPx, startPy] = lngLatToWebMercatorPx(start[0], start[1], zoom, tileSize);
8695
- const [endPx, endPy] = lngLatToWebMercatorPx(end[0], end[1], zoom, tileSize);
8696
- const angleDeg = normalizeReadableAngle(Math.atan2(endPy - startPy, endPx - startPx) * RAD_TO_DEG);
8907
+ let angleDeg;
8908
+ if (geodesic) {
8909
+ const delta = reactMapAdapterShared.angularDistance(start[0], start[1], end[0], end[1]);
8910
+ if (delta > 0) {
8911
+ // Finite-difference tangent at the arc midpoint (t = 0.5).
8912
+ const TANGENT_EPS = 0.001;
8913
+ const p0 = reactMapAdapterShared.intermediatePoint(start, end, 0.5 - TANGENT_EPS, delta);
8914
+ const p1 = reactMapAdapterShared.intermediatePoint(start, end, 0.5 + TANGENT_EPS, delta);
8915
+ const [bx, by] = lngLatToWebMercatorPx(p0[0], p0[1], zoom, tileSize);
8916
+ const [ax, ay] = lngLatToWebMercatorPx(p1[0], p1[1], zoom, tileSize);
8917
+ angleDeg = normalizeReadableAngle(Math.atan2(ay - by, ax - bx) * RAD_TO_DEG);
8918
+ }
8919
+ else {
8920
+ const [startPx, startPy] = lngLatToWebMercatorPx(start[0], start[1], zoom, tileSize);
8921
+ const [endPx, endPy] = lngLatToWebMercatorPx(end[0], end[1], zoom, tileSize);
8922
+ angleDeg = normalizeReadableAngle(Math.atan2(endPy - startPy, endPx - startPx) * RAD_TO_DEG);
8923
+ }
8924
+ }
8925
+ else {
8926
+ const [startPx, startPy] = lngLatToWebMercatorPx(start[0], start[1], zoom, tileSize);
8927
+ const [endPx, endPy] = lngLatToWebMercatorPx(end[0], end[1], zoom, tileSize);
8928
+ angleDeg = normalizeReadableAngle(Math.atan2(endPy - startPy, endPx - startPx) * RAD_TO_DEG);
8929
+ }
8697
8930
  const pixelLength = geoJsonUtils.edgePixelLength(start[0], start[1], end[0], end[1], zoom, midLat, tileSize);
8698
8931
  let outwardSide = "above";
8699
8932
  if (!isLineGeometry(geometry)) {
@@ -8958,39 +9191,60 @@ const featureBbox = (feature) => {
8958
9191
  return [minLng, minLat, maxLng, maxLat];
8959
9192
  };
8960
9193
  const bboxesIntersect = (a, b) => a[2] >= b[0] && a[0] <= b[2] && a[3] >= b[1] && a[1] <= b[3];
8961
- const countOverlappingShapes = (feature, featureBboxes, viewportBounds) => {
8962
- const bbox = featureBboxes.get(feature);
8963
- if (bbox === undefined || bbox === null)
8964
- return 0;
8965
- const geom = feature.geometry;
8966
- const isPolygonal = geom !== null && (geom.type === "Polygon" || geom.type === "MultiPolygon");
8967
- let count = 0;
8968
- for (const [otherFeature, otherBbox] of featureBboxes) {
8969
- if (otherFeature === feature || otherBbox === null)
9194
+ /**
9195
+ * Compute per-feature overlap counts for all features in one O() pass.
9196
+ *
9197
+ * Previously `countOverlappingShapes` was called once per feature, re-scanning
9198
+ * every other feature and re-running polygon intersection for the same pairs —
9199
+ * O(n³) intersection work per handle per pan frame. Each unordered pair is
9200
+ * evaluated at most once here.
9201
+ */
9202
+ const buildOverlappingShapesCountMap = (features, featureBboxes, viewportBounds) => {
9203
+ const counts = new Map();
9204
+ for (const feature of features) {
9205
+ counts.set(feature, 0);
9206
+ }
9207
+ for (let i = 0; i < features.length; i++) {
9208
+ const featureA = features[i];
9209
+ if (featureA === undefined)
8970
9210
  continue;
8971
- if (!bboxesIntersect(otherBbox, viewportBounds))
9211
+ const bboxA = featureBboxes.get(featureA);
9212
+ if (bboxA === undefined || bboxA === null)
8972
9213
  continue;
8973
- if (!bboxesIntersect(bbox, otherBbox))
9214
+ if (!bboxesIntersect(bboxA, viewportBounds))
8974
9215
  continue;
8975
- const otherGeom = otherFeature.geometry;
8976
- const otherIsPolygonal = otherGeom !== null && (otherGeom.type === "Polygon" || otherGeom.type === "MultiPolygon");
8977
- if (isPolygonal && otherIsPolygonal) {
8978
- // Precise polygon intersection — bbox was a prefilter only
8979
- if (geoJsonUtils.getGeoJsonPolygonIntersection(geom, otherGeom) !== null) {
8980
- // If this feature is fully contained inside the other, its fill does not
8981
- // obscure the base map layer below — only the outer's count increments.
8982
- if (geoJsonUtils.isFullyContainedInGeoJsonGeometry(geom, otherGeom) === true) {
8983
- continue;
9216
+ const geomA = featureA.geometry;
9217
+ const isPolygonalA = geomA !== null && (geomA.type === "Polygon" || geomA.type === "MultiPolygon");
9218
+ for (let j = i + 1; j < features.length; j++) {
9219
+ const featureB = features[j];
9220
+ if (featureB === undefined)
9221
+ continue;
9222
+ const bboxB = featureBboxes.get(featureB);
9223
+ if (bboxB === undefined || bboxB === null)
9224
+ continue;
9225
+ if (!bboxesIntersect(bboxB, viewportBounds))
9226
+ continue;
9227
+ if (!bboxesIntersect(bboxA, bboxB))
9228
+ continue;
9229
+ const geomB = featureB.geometry;
9230
+ const isPolygonalB = geomB !== null && (geomB.type === "Polygon" || geomB.type === "MultiPolygon");
9231
+ if (isPolygonalA && isPolygonalB) {
9232
+ if (geoJsonUtils.getGeoJsonPolygonIntersection(geomA, geomB) !== null) {
9233
+ if (geoJsonUtils.isFullyContainedInGeoJsonGeometry(geomA, geomB) !== true) {
9234
+ counts.set(featureA, (counts.get(featureA) ?? 0) + 1);
9235
+ }
9236
+ if (geoJsonUtils.isFullyContainedInGeoJsonGeometry(geomB, geomA) !== true) {
9237
+ counts.set(featureB, (counts.get(featureB) ?? 0) + 1);
9238
+ }
8984
9239
  }
8985
- count++;
8986
9240
  }
8987
- }
8988
- else {
8989
- // Points and lines keep bbox-only overlap (geometries have no fill area)
8990
- count++;
9241
+ else {
9242
+ counts.set(featureA, (counts.get(featureA) ?? 0) + 1);
9243
+ counts.set(featureB, (counts.get(featureB) ?? 0) + 1);
9244
+ }
8991
9245
  }
8992
9246
  }
8993
- return count;
9247
+ return counts;
8994
9248
  };
8995
9249
  /**
8996
9250
  * Value-based equality for the nested style overrides maps. Used to skip
@@ -9129,6 +9383,7 @@ const useShapeDecorations = ({ onDecorationsChange, onStyleOverridesChange, api,
9129
9383
  }
9130
9384
  return shapesInViewportCache;
9131
9385
  };
9386
+ const overlappingCounts = buildOverlappingShapesCountMap(handle.features.features, featureBboxes, bounds);
9132
9387
  handle.features.features.forEach((feature, index) => {
9133
9388
  const geometry = feature.geometry;
9134
9389
  if (geometry === null || geometry.type === "GeometryCollection")
@@ -9141,7 +9396,7 @@ const useShapeDecorations = ({ onDecorationsChange, onStyleOverridesChange, api,
9141
9396
  zoom,
9142
9397
  tileSize,
9143
9398
  shapesInViewport: shapesInViewport(),
9144
- overlappingShapesCount: countOverlappingShapes(feature, featureBboxes, bounds),
9399
+ overlappingShapesCount: overlappingCounts.get(feature) ?? 0,
9145
9400
  interaction: currentInteraction,
9146
9401
  });
9147
9402
  const featureStyle = resolutionContext === null ? handle.resolveStyle(feature) : handle.resolveStyle(feature, resolutionContext);
@@ -9191,7 +9446,7 @@ const useShapeDecorations = ({ onDecorationsChange, onStyleOverridesChange, api,
9191
9446
  ...(decoration.sourceProperties ?? {}),
9192
9447
  };
9193
9448
  if (resolved.edgeEndpoints !== null) {
9194
- const edgeProps = computeEdgeProperties(resolved.edgeEndpoints.start, resolved.edgeEndpoints.end, geometry, zoom, tileSize);
9449
+ const edgeProps = computeEdgeProperties(resolved.edgeEndpoints.start, resolved.edgeEndpoints.end, geometry, zoom, tileSize, featureStyle.geodesic ?? true);
9195
9450
  properties = { ...properties, ...edgeProps };
9196
9451
  }
9197
9452
  newLayers.push({
@@ -9284,6 +9539,7 @@ const useShapeDecorations = ({ onDecorationsChange, onStyleOverridesChange, api,
9284
9539
  labelAnchor: anchor.labelAnchor,
9285
9540
  labelPlacementResolver: anchor.labelPlacementResolver,
9286
9541
  mode,
9542
+ geodesic: featureStyle.geodesic ?? true,
9287
9543
  });
9288
9544
  switch (outcome.type) {
9289
9545
  case "placed": {
@@ -9747,7 +10003,7 @@ const useShapeFillTiling = ({ api, handles, onFillGeometriesChange, onZIndexOver
9747
10003
  if (restingClip !== undefined)
9748
10004
  restingPeerFills.set(featureId, restingClip);
9749
10005
  }
9750
- const peerFills = computePromotionGroupFills(groupMembers, winnerId, restingPeerFills);
10006
+ const peerFills = computePromotionGroupFills(groupMembers, winnerId, restingPeerFills, handle?.style.geodesic, handle?.featureStyles);
9751
10007
  modifiedFills.delete(winnerId);
9752
10008
  for (const [featureId, clip] of peerFills) {
9753
10009
  modifiedFills.set(featureId, clip);
@@ -9800,12 +10056,28 @@ const useShapeFillTiling = ({ api, handles, onFillGeometriesChange, onZIndexOver
9800
10056
  .sort(([a], [b]) => (a < b ? -1 : 1))
9801
10057
  .map(([handleId, ids]) => `${handleId}:${[...ids].sort().join(",")}`)
9802
10058
  .join(";");
10059
+ // Geodesic key: per-handle layer flag + sorted per-feature geodesic overrides.
10060
+ // Toggling geodesic (layer or per-feature) must recompute instead of serving
10061
+ // a stale clip (mirrors suppressedKey shape).
10062
+ const geodesicKey = currentHandles
10063
+ .map(handle => {
10064
+ const layerFlag = handle.style.geodesic;
10065
+ const featureFlags = handle.featureStyles
10066
+ ? [...handle.featureStyles.entries()]
10067
+ .filter(([, style]) => style.geodesic !== undefined)
10068
+ .sort(([a], [b]) => (a < b ? -1 : 1))
10069
+ .map(([id, style]) => `${id}:${String(style.geodesic)}`)
10070
+ .join(",")
10071
+ : "";
10072
+ return `${handle.id}:${String(layerFlag)}:${featureFlags}`;
10073
+ })
10074
+ .join(";");
9803
10075
  // Bounds are intentionally excluded from the inputKey. Clip geometry depends on
9804
10076
  // zoom (which affects stack order via resolveStackOrder) and feature geometry —
9805
10077
  // not on the visible viewport region. Using global bounds means all overlapping
9806
10078
  // features always have pre-computed clips, so polygons entering the viewport
9807
10079
  // during zoom-out never flash their unclipped fill.
9808
- const inputKey = `${tilingContentKeyRef.current}|${currentViewport.zoom}|${selectedFeatureIdRef.current ?? ""}|${suppressedKey}`;
10080
+ const inputKey = `${tilingContentKeyRef.current}|${currentViewport.zoom}|${selectedFeatureIdRef.current ?? ""}|${suppressedKey}|${geodesicKey}`;
9809
10081
  if (inputKey === lastComputeInputKeyRef.current) {
9810
10082
  return;
9811
10083
  }
@@ -9836,6 +10108,8 @@ const useShapeFillTiling = ({ api, handles, onFillGeometriesChange, onZIndexOver
9836
10108
  zoom: currentViewport.zoom,
9837
10109
  selectedFeatureId: selectedFeatureIdRef.current,
9838
10110
  suppressedFeatureIds: suppressedFillIdsByHandleRef.current?.get(handle.id),
10111
+ layerGeodesic: handle.style.geodesic,
10112
+ featureStyles: handle.featureStyles,
9839
10113
  });
9840
10114
  featureToGroupKeyByHandleRef.current.set(handle.id, new Map(featureToGroupKey));
9841
10115
  if (fillGeometries.size > 0) {
@@ -9952,6 +10226,8 @@ const useShapeFillTiling = ({ api, handles, onFillGeometriesChange, onZIndexOver
9952
10226
  tileSize: currentViewport.tileSize,
9953
10227
  strokeWidthFor,
9954
10228
  visibleFillFor,
10229
+ layerGeodesic: handle.style.geodesic,
10230
+ featureStyles: handle.featureStyles,
9955
10231
  });
9956
10232
  handle.onShapesUnderCursor?.(hits, { position });
9957
10233
  settleHitsByHandle.set(handle.id, hits);
@@ -10109,6 +10385,8 @@ const useShapeFillTiling = ({ api, handles, onFillGeometriesChange, onZIndexOver
10109
10385
  tileSize,
10110
10386
  strokeWidthFor,
10111
10387
  visibleFillFor,
10388
+ layerGeodesic: handle.style.geodesic,
10389
+ featureStyles: handle.featureStyles,
10112
10390
  });
10113
10391
  }, []);
10114
10392
  const setDecorationHoverActive = react.useCallback((active) => {