@octostar/map-component 0.2.22 → 0.3.1
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 +656 -382
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +656 -382
- package/dist/index.mjs.map +1 -1
- package/dist/types/components/drawing-toolbar.d.ts +4 -6
- package/dist/types/components/drawing-toolbar.d.ts.map +1 -1
- package/dist/types/components/layers-panel.d.ts +1 -1
- package/dist/types/components/layers-panel.d.ts.map +1 -1
- package/dist/types/components/map-editor-canvas.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/basemap-list.d.ts +15 -6
- package/dist/types/lib/basemap-list.d.ts.map +1 -1
- package/dist/types/lib/custom-layer-stack.d.ts +20 -7
- package/dist/types/lib/custom-layer-stack.d.ts.map +1 -1
- package/dist/types/lib/label-pinning.d.ts +10 -2
- package/dist/types/lib/label-pinning.d.ts.map +1 -1
- package/dist/types/lib/map-editor-api.d.ts +80 -47
- package/dist/types/lib/map-editor-api.d.ts.map +1 -1
- package/dist/types/lib/map-endpoints.d.ts +71 -0
- package/dist/types/lib/map-endpoints.d.ts.map +1 -0
- package/dist/types/lib/paint-feature.d.ts +11 -11
- package/dist/types/lib/paint-feature.d.ts.map +1 -1
- package/dist/types/lib/selection-diff.d.ts +9 -34
- package/dist/types/lib/selection-diff.d.ts.map +1 -1
- package/dist/types/lib/selection-overlay.d.ts +53 -0
- package/dist/types/lib/selection-overlay.d.ts.map +1 -0
- package/dist/types/lib/selection-paint.d.ts +23 -0
- package/dist/types/lib/selection-paint.d.ts.map +1 -0
- package/dist/types/lib/selection-state.d.ts +60 -0
- package/dist/types/lib/selection-state.d.ts.map +1 -0
- package/dist/types/lib/shard-fingerprint.d.ts +6 -7
- package/dist/types/lib/shard-fingerprint.d.ts.map +1 -1
- package/dist/types/lib/shard-locator.d.ts +53 -0
- package/dist/types/lib/shard-locator.d.ts.map +1 -0
- package/dist/types/lib/shard-pipeline.d.ts.map +1 -1
- package/dist/types/lib/shard-registry.d.ts +5 -4
- package/dist/types/lib/shard-registry.d.ts.map +1 -1
- package/dist/types/lib/trace-timeline.d.ts +3 -6
- package/dist/types/lib/trace-timeline.d.ts.map +1 -1
- package/package.json +1 -1
- package/vite-plugin.d.mts +2 -0
- package/vite-plugin.mjs +42 -8
package/dist/index.mjs
CHANGED
|
@@ -748,6 +748,10 @@ function createIngestProgressStore() {
|
|
|
748
748
|
}
|
|
749
749
|
};
|
|
750
750
|
}
|
|
751
|
+
const SELECTED_STATE_KEY = "selected";
|
|
752
|
+
const SELECTED = ["boolean", ["feature-state", SELECTED_STATE_KEY], false];
|
|
753
|
+
const SELECTED_STATE = Object.freeze({ [SELECTED_STATE_KEY]: true });
|
|
754
|
+
const SELECTION_COLOR = "#06b6d4";
|
|
751
755
|
const LABEL_NEVER_HIDE_PROP = "_labelNeverHide";
|
|
752
756
|
const PINNED_LABEL_FILTER = ["==", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
753
757
|
const UNPINNED_LABEL_FILTER = ["!=", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
@@ -800,7 +804,8 @@ function buildCustomLabelLayout() {
|
|
|
800
804
|
]
|
|
801
805
|
};
|
|
802
806
|
}
|
|
803
|
-
function buildCustomLabelPaint() {
|
|
807
|
+
function buildCustomLabelPaint(opts) {
|
|
808
|
+
const visibleOpacity = ["*", 0.9, ["get", "stroke-opacity"]];
|
|
804
809
|
return {
|
|
805
810
|
// Text features use fontColor; others use default
|
|
806
811
|
"text-color": [
|
|
@@ -819,7 +824,7 @@ function buildCustomLabelPaint() {
|
|
|
819
824
|
2,
|
|
820
825
|
1.5
|
|
821
826
|
],
|
|
822
|
-
"text-opacity":
|
|
827
|
+
"text-opacity": (opts == null ? void 0 : opts.hideSelected) ? ["case", SELECTED, 0, visibleOpacity] : visibleOpacity
|
|
823
828
|
};
|
|
824
829
|
}
|
|
825
830
|
const CUSTOM_LAYER_ROLES = [
|
|
@@ -829,13 +834,13 @@ const CUSTOM_LAYER_ROLES = [
|
|
|
829
834
|
"point-shadow",
|
|
830
835
|
"point",
|
|
831
836
|
"point-icon",
|
|
832
|
-
"point-icon-selection",
|
|
833
|
-
"line-selection",
|
|
834
|
-
"polygon-selection",
|
|
835
837
|
"labels",
|
|
836
838
|
"labels-pinned"
|
|
837
839
|
];
|
|
838
840
|
const SHARED_SOURCE_ID = "custom-features";
|
|
841
|
+
function customSourceSpec() {
|
|
842
|
+
return { type: "geojson", data: { type: "FeatureCollection", features: [] }, maxzoom: 22, promoteId: "id" };
|
|
843
|
+
}
|
|
839
844
|
const EMOJI_CANVAS_SIZE = 48;
|
|
840
845
|
function customLayerId(role, sourceId) {
|
|
841
846
|
return sourceId === SHARED_SOURCE_ID ? `custom-${role}` : `custom-${role}@${sourceId}`;
|
|
@@ -858,9 +863,9 @@ function geometryClassesOf(features) {
|
|
|
858
863
|
return classes;
|
|
859
864
|
}
|
|
860
865
|
const ROLES_BY_CLASS = {
|
|
861
|
-
polygon: ["polygon-fill", "polygon-stroke"
|
|
862
|
-
line: ["line"
|
|
863
|
-
point: ["point-shadow", "point", "point-icon"
|
|
866
|
+
polygon: ["polygon-fill", "polygon-stroke"],
|
|
867
|
+
line: ["line"],
|
|
868
|
+
point: ["point-shadow", "point", "point-icon"]
|
|
864
869
|
};
|
|
865
870
|
function rolesForGeometry(classes) {
|
|
866
871
|
const needed = /* @__PURE__ */ new Set(["labels", "labels-pinned"]);
|
|
@@ -882,12 +887,6 @@ function shardInsertAnchor(role) {
|
|
|
882
887
|
case "point":
|
|
883
888
|
return "custom-point-icon";
|
|
884
889
|
case "point-icon":
|
|
885
|
-
return "custom-point-icon-selection";
|
|
886
|
-
case "point-icon-selection":
|
|
887
|
-
return "custom-line-selection";
|
|
888
|
-
case "line-selection":
|
|
889
|
-
return "custom-polygon-selection";
|
|
890
|
-
case "polygon-selection":
|
|
891
890
|
return "custom-arrow-heads";
|
|
892
891
|
case "labels":
|
|
893
892
|
return "custom-arrow-heads";
|
|
@@ -970,7 +969,8 @@ function buildLayer(role, sourceId, opts) {
|
|
|
970
969
|
"circle-translate": [1, 1]
|
|
971
970
|
}
|
|
972
971
|
};
|
|
973
|
-
// Custom point layer
|
|
972
|
+
// Custom point layer; the selection ring is paint-only and reads feature
|
|
973
|
+
// state (hidden when emoji icon is set)
|
|
974
974
|
case "point":
|
|
975
975
|
return {
|
|
976
976
|
id,
|
|
@@ -1001,7 +1001,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1001
1001
|
0,
|
|
1002
1002
|
["coalesce", ["get", "stroke-opacity"], 1]
|
|
1003
1003
|
],
|
|
1004
|
-
"circle-stroke-color": ["case",
|
|
1004
|
+
"circle-stroke-color": ["case", SELECTED, SELECTION_COLOR, "#555555"],
|
|
1005
1005
|
"circle-stroke-width": [
|
|
1006
1006
|
"case",
|
|
1007
1007
|
["==", ["get", "isTimelineHidden"], 1],
|
|
@@ -1012,7 +1012,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1012
1012
|
0,
|
|
1013
1013
|
["!=", ["get", "icon"], ""],
|
|
1014
1014
|
0,
|
|
1015
|
-
|
|
1015
|
+
SELECTED,
|
|
1016
1016
|
3,
|
|
1017
1017
|
1.5
|
|
1018
1018
|
],
|
|
@@ -1052,47 +1052,6 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1052
1052
|
]
|
|
1053
1053
|
}
|
|
1054
1054
|
};
|
|
1055
|
-
// Selection ring for icon points
|
|
1056
|
-
case "point-icon-selection":
|
|
1057
|
-
return {
|
|
1058
|
-
id,
|
|
1059
|
-
type: "circle",
|
|
1060
|
-
source: sourceId,
|
|
1061
|
-
filter: ["all", ["==", "$type", "Point"], ["!=", "icon", ""], ["==", "isSelected", 1], ["!=", "isHiddenByHeatmap", 1]],
|
|
1062
|
-
paint: {
|
|
1063
|
-
"circle-color": "transparent",
|
|
1064
|
-
"circle-radius": ["/", ["coalesce", ["get", "iconSize"], 24], 1.6],
|
|
1065
|
-
"circle-stroke-color": "#06b6d4",
|
|
1066
|
-
"circle-stroke-width": 3,
|
|
1067
|
-
"circle-stroke-opacity": 1
|
|
1068
|
-
}
|
|
1069
|
-
};
|
|
1070
|
-
// Selection highlight for lines - bright cyan dashed overlay
|
|
1071
|
-
case "line-selection":
|
|
1072
|
-
return {
|
|
1073
|
-
id,
|
|
1074
|
-
type: "line",
|
|
1075
|
-
source: sourceId,
|
|
1076
|
-
filter: ["all", ["==", "$type", "LineString"], ["==", "isSelected", 1]],
|
|
1077
|
-
paint: {
|
|
1078
|
-
"line-color": "#06b6d4",
|
|
1079
|
-
"line-width": ["+", ["get", "stroke-width"], 4],
|
|
1080
|
-
"line-dasharray": [4, 2]
|
|
1081
|
-
}
|
|
1082
|
-
};
|
|
1083
|
-
// Selection highlight for polygons - bright cyan dashed outline
|
|
1084
|
-
case "polygon-selection":
|
|
1085
|
-
return {
|
|
1086
|
-
id,
|
|
1087
|
-
type: "line",
|
|
1088
|
-
source: sourceId,
|
|
1089
|
-
filter: ["all", ["==", "$type", "Polygon"], ["==", "isSelected", 1]],
|
|
1090
|
-
paint: {
|
|
1091
|
-
"line-color": "#06b6d4",
|
|
1092
|
-
"line-width": 4,
|
|
1093
|
-
"line-dasharray": [4, 2]
|
|
1094
|
-
}
|
|
1095
|
-
};
|
|
1096
1055
|
// Label layer for all features - shows 'name' property, or 'text' for text features
|
|
1097
1056
|
// Trace labels are slightly bigger and bolder, hidden points have no labels
|
|
1098
1057
|
// Arrow labels are handled separately by the custom-arrow-labels layer.
|
|
@@ -1118,8 +1077,11 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1118
1077
|
//
|
|
1119
1078
|
// The fix has two parts:
|
|
1120
1079
|
// 1. (here) Re-enable collision and use `symbol-sort-key` to control
|
|
1121
|
-
// intra-layer priority.
|
|
1122
|
-
// ordinary points so they keep their labels when crowded.
|
|
1080
|
+
// intra-layer priority. Text/trace features win against
|
|
1081
|
+
// ordinary points so they keep their labels when crowded. A
|
|
1082
|
+
// selected feature's label is drawn by the selection overlay;
|
|
1083
|
+
// its copy here is hidden through `text-opacity` but still
|
|
1084
|
+
// laid out, so it claims the same collision space as before.
|
|
1123
1085
|
// 2. (see `moveLabelsBeforeBasemapSymbols` in the canvas) After each
|
|
1124
1086
|
// basemap load, move the label layers BEFORE basemap symbol layers
|
|
1125
1087
|
// in the style stack. MapLibre processes collision in painter
|
|
@@ -1137,7 +1099,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1137
1099
|
// Computed per-feature in styleFeatureForPaint.
|
|
1138
1100
|
"symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100]
|
|
1139
1101
|
},
|
|
1140
|
-
paint: buildCustomLabelPaint()
|
|
1102
|
+
paint: buildCustomLabelPaint({ hideSelected: true })
|
|
1141
1103
|
};
|
|
1142
1104
|
// Pinned twin of the labels layer for layers with visualConfig.label.neverHide.
|
|
1143
1105
|
// text-allow-overlap / text-ignore-placement are data-constant in MapLibre
|
|
@@ -1163,7 +1125,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1163
1125
|
// (low-priority-value) labels draw over their neighbours' halos.
|
|
1164
1126
|
"symbol-sort-key": ["*", -1, ["coalesce", ["get", "_labelPriority"], 100]]
|
|
1165
1127
|
},
|
|
1166
|
-
paint: buildCustomLabelPaint()
|
|
1128
|
+
paint: buildCustomLabelPaint({ hideSelected: true })
|
|
1167
1129
|
};
|
|
1168
1130
|
}
|
|
1169
1131
|
}
|
|
@@ -1214,7 +1176,7 @@ function resolveShardSize(value) {
|
|
|
1214
1176
|
}
|
|
1215
1177
|
return Math.floor(value);
|
|
1216
1178
|
}
|
|
1217
|
-
function buildShardFingerprint(layer, features,
|
|
1179
|
+
function buildShardFingerprint(layer, features, shardSize) {
|
|
1218
1180
|
return {
|
|
1219
1181
|
features,
|
|
1220
1182
|
visualConfig: layer.visualConfig,
|
|
@@ -1222,36 +1184,30 @@ function buildShardFingerprint(layer, features, selectionEnabled, shardSize) {
|
|
|
1222
1184
|
clusterConfig: layer.clusterConfig,
|
|
1223
1185
|
altitudeDisplayMode: layer.altitudeDisplayMode,
|
|
1224
1186
|
hasAltitudeData: layer.hasAltitudeData,
|
|
1225
|
-
selectionEnabled,
|
|
1226
1187
|
shardSize
|
|
1227
1188
|
};
|
|
1228
1189
|
}
|
|
1229
1190
|
function shardFingerprintsEqual(a, b) {
|
|
1230
1191
|
if (!a || !b) return false;
|
|
1231
|
-
return Object.is(a.features, b.features) && Object.is(a.visualConfig, b.visualConfig) && Object.is(a.heatmapConfig, b.heatmapConfig) && Object.is(a.clusterConfig, b.clusterConfig) && Object.is(a.altitudeDisplayMode, b.altitudeDisplayMode) && Object.is(a.hasAltitudeData, b.hasAltitudeData) && Object.is(a.
|
|
1192
|
+
return Object.is(a.features, b.features) && Object.is(a.visualConfig, b.visualConfig) && Object.is(a.heatmapConfig, b.heatmapConfig) && Object.is(a.clusterConfig, b.clusterConfig) && Object.is(a.altitudeDisplayMode, b.altitudeDisplayMode) && Object.is(a.hasAltitudeData, b.hasAltitudeData) && Object.is(a.shardSize, b.shardSize);
|
|
1232
1193
|
}
|
|
1233
|
-
const DEFAULT_LABEL_PRIORITY = 100;
|
|
1234
1194
|
const DEFAULT_VISIBLE_STROKE_OPACITY = 1;
|
|
1235
1195
|
const DEFAULT_VISIBLE_FILL_OPACITY = 0.2;
|
|
1236
1196
|
function createSelectionPaintCache() {
|
|
1237
1197
|
return {
|
|
1238
1198
|
presentIds: /* @__PURE__ */ new Set(),
|
|
1239
|
-
appliedSelectedIds: /* @__PURE__ */ new Set(),
|
|
1240
|
-
basePriorityById: /* @__PURE__ */ new Map(),
|
|
1241
1199
|
appliedHiddenIds: /* @__PURE__ */ new Set(),
|
|
1242
1200
|
visibleStrokeOpacityById: /* @__PURE__ */ new Map(),
|
|
1243
1201
|
visibleFillOpacityById: /* @__PURE__ */ new Map(),
|
|
1244
1202
|
updatable: true
|
|
1245
1203
|
};
|
|
1246
1204
|
}
|
|
1247
|
-
function recordPaintedFeature(cache2, featureId,
|
|
1205
|
+
function recordPaintedFeature(cache2, featureId, visibleStrokeOpacity, visibleFillOpacity, isTimelineHidden) {
|
|
1248
1206
|
if (cache2.presentIds.has(featureId)) {
|
|
1249
1207
|
cache2.updatable = false;
|
|
1250
1208
|
} else {
|
|
1251
1209
|
cache2.presentIds.add(featureId);
|
|
1252
1210
|
}
|
|
1253
|
-
cache2.basePriorityById.set(featureId, basePriority);
|
|
1254
|
-
if (isSelected) cache2.appliedSelectedIds.add(featureId);
|
|
1255
1211
|
if (visibleStrokeOpacity !== DEFAULT_VISIBLE_STROKE_OPACITY) {
|
|
1256
1212
|
cache2.visibleStrokeOpacityById.set(featureId, visibleStrokeOpacity);
|
|
1257
1213
|
}
|
|
@@ -1260,52 +1216,9 @@ function recordPaintedFeature(cache2, featureId, basePriority, isSelected, visib
|
|
|
1260
1216
|
}
|
|
1261
1217
|
if (isTimelineHidden) cache2.appliedHiddenIds.add(featureId);
|
|
1262
1218
|
}
|
|
1263
|
-
function applySelectionFastPath(cache2, nextSelectedIds, source) {
|
|
1264
|
-
if (!cache2 || !cache2.updatable || !source) return false;
|
|
1265
|
-
const diff = buildSelectionDiff(cache2, nextSelectedIds);
|
|
1266
|
-
if (diff) {
|
|
1267
|
-
try {
|
|
1268
|
-
source.updateData(diff);
|
|
1269
|
-
} catch {
|
|
1270
|
-
return false;
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
const applied = /* @__PURE__ */ new Set();
|
|
1274
|
-
nextSelectedIds.forEach((id) => {
|
|
1275
|
-
if (cache2.presentIds.has(id)) applied.add(id);
|
|
1276
|
-
});
|
|
1277
|
-
cache2.appliedSelectedIds = applied;
|
|
1278
|
-
return true;
|
|
1279
|
-
}
|
|
1280
1219
|
function needsDrawSelectionUpdate(input) {
|
|
1281
1220
|
return input.editableSelectionCount > 0 || input.drawSelectedCount > 0 || input.currentMode !== input.targetMode;
|
|
1282
1221
|
}
|
|
1283
|
-
function buildSelectionDiff(cache2, nextSelectedIds) {
|
|
1284
|
-
const update = [];
|
|
1285
|
-
cache2.appliedSelectedIds.forEach((id) => {
|
|
1286
|
-
if (!nextSelectedIds.has(id) && cache2.presentIds.has(id)) {
|
|
1287
|
-
update.push({
|
|
1288
|
-
id,
|
|
1289
|
-
addOrUpdateProperties: [
|
|
1290
|
-
{ key: "isSelected", value: 0 },
|
|
1291
|
-
{ key: "_labelPriority", value: cache2.basePriorityById.get(id) ?? DEFAULT_LABEL_PRIORITY }
|
|
1292
|
-
]
|
|
1293
|
-
});
|
|
1294
|
-
}
|
|
1295
|
-
});
|
|
1296
|
-
nextSelectedIds.forEach((id) => {
|
|
1297
|
-
if (!cache2.appliedSelectedIds.has(id) && cache2.presentIds.has(id)) {
|
|
1298
|
-
update.push({
|
|
1299
|
-
id,
|
|
1300
|
-
addOrUpdateProperties: [
|
|
1301
|
-
{ key: "isSelected", value: 1 },
|
|
1302
|
-
{ key: "_labelPriority", value: 0 }
|
|
1303
|
-
]
|
|
1304
|
-
});
|
|
1305
|
-
}
|
|
1306
|
-
});
|
|
1307
|
-
return update.length > 0 ? { update } : null;
|
|
1308
|
-
}
|
|
1309
1222
|
function buildTimelineVisibilityDiff(cache2, nextVisibleSet) {
|
|
1310
1223
|
const update = [];
|
|
1311
1224
|
const nextHiddenIds = /* @__PURE__ */ new Set();
|
|
@@ -1349,7 +1262,6 @@ function applyTimelineFastPath(cache2, nextVisibleSet, source) {
|
|
|
1349
1262
|
cache2.appliedHiddenIds = nextHiddenIds;
|
|
1350
1263
|
return { applied: true, toggled: ((_a = diff == null ? void 0 : diff.update) == null ? void 0 : _a.length) ?? 0 };
|
|
1351
1264
|
}
|
|
1352
|
-
const EMPTY_COLLECTION = { type: "FeatureCollection", features: [] };
|
|
1353
1265
|
const INTERACTIVE_ROLES = ["point", "line", "polygon-fill"];
|
|
1354
1266
|
function createShardRegistry(host, hooks) {
|
|
1355
1267
|
const states = /* @__PURE__ */ new Map();
|
|
@@ -1382,7 +1294,7 @@ function createShardRegistry(host, hooks) {
|
|
|
1382
1294
|
};
|
|
1383
1295
|
const createStack = (state, index, roles, data) => {
|
|
1384
1296
|
const sourceId = shardSourceId(state.layerId, index);
|
|
1385
|
-
host.addSource(sourceId,
|
|
1297
|
+
host.addSource(sourceId, customSourceSpec());
|
|
1386
1298
|
const specs = buildCustomLayerStack(sourceId, roles, { labelsVisible: hooks.labelsVisible() });
|
|
1387
1299
|
const ordered = CUSTOM_LAYER_ROLES.filter((role) => roles.includes(role));
|
|
1388
1300
|
const layerIds = [];
|
|
@@ -1523,7 +1435,7 @@ function createShardRegistry(host, hooks) {
|
|
|
1523
1435
|
}
|
|
1524
1436
|
};
|
|
1525
1437
|
}
|
|
1526
|
-
function reconcileShardCaches(registry, layerId, expectedShards,
|
|
1438
|
+
function reconcileShardCaches(registry, layerId, expectedShards, visibleIds) {
|
|
1527
1439
|
const state = registry.state(layerId);
|
|
1528
1440
|
if (!state || state.stacks.length !== expectedShards) return false;
|
|
1529
1441
|
for (let i = 0; i < expectedShards; i++) {
|
|
@@ -1532,7 +1444,6 @@ function reconcileShardCaches(registry, layerId, expectedShards, selectedIds, vi
|
|
|
1532
1444
|
const source = registry.sourceFor(layerId, i);
|
|
1533
1445
|
if (!source) return false;
|
|
1534
1446
|
if (!applyTimelineFastPath(cache2, visibleIds, source).applied) return false;
|
|
1535
|
-
if (!applySelectionFastPath(cache2, selectedIds, source)) return false;
|
|
1536
1447
|
}
|
|
1537
1448
|
return true;
|
|
1538
1449
|
}
|
|
@@ -1787,7 +1698,7 @@ const TRACE_ENDPOINT_LABEL_PRIORITY = 5;
|
|
|
1787
1698
|
const TRACE_POINT_RADIUS = 2;
|
|
1788
1699
|
const TRACE_ENDPOINT_MIN_RADIUS = 8;
|
|
1789
1700
|
function buildTraceTimelineDiff(trace, paint, nextVisibleSet) {
|
|
1790
|
-
const diff = { pointUpdates: [], segmentAdd: [], segmentRemove: []
|
|
1701
|
+
const diff = { pointUpdates: [], segmentAdd: [], segmentRemove: [] };
|
|
1791
1702
|
const paintedVisible = (id) => !paint.appliedHiddenIds.has(id);
|
|
1792
1703
|
const nextVisible = timelineVisibility(nextVisibleSet);
|
|
1793
1704
|
trace.groups.forEach((group, groupIndex) => {
|
|
@@ -1796,8 +1707,8 @@ function buildTraceTimelineDiff(trace, paint, nextVisibleSet) {
|
|
|
1796
1707
|
const prevEndpoint = prev.length > 0 ? prev[prev.length - 1] : -1;
|
|
1797
1708
|
const nextEndpoint = next.length > 0 ? next[next.length - 1] : -1;
|
|
1798
1709
|
if (prevEndpoint !== nextEndpoint) {
|
|
1799
|
-
if (prevEndpoint >= 0) pushEndpointUpdate(diff, trace,
|
|
1800
|
-
if (nextEndpoint >= 0) pushEndpointUpdate(diff, trace,
|
|
1710
|
+
if (prevEndpoint >= 0) pushEndpointUpdate(diff, trace, group, group.ids[prevEndpoint], false);
|
|
1711
|
+
if (nextEndpoint >= 0) pushEndpointUpdate(diff, trace, group, group.ids[nextEndpoint], true);
|
|
1801
1712
|
}
|
|
1802
1713
|
diffConsecutivePairs(
|
|
1803
1714
|
prev,
|
|
@@ -1808,21 +1719,19 @@ function buildTraceTimelineDiff(trace, paint, nextVisibleSet) {
|
|
|
1808
1719
|
});
|
|
1809
1720
|
return diff;
|
|
1810
1721
|
}
|
|
1811
|
-
function pushEndpointUpdate(diff, trace,
|
|
1722
|
+
function pushEndpointUpdate(diff, trace, group, id, isEndpoint) {
|
|
1812
1723
|
const point2 = trace.pointPaint.get(id);
|
|
1813
1724
|
if (!point2) return;
|
|
1814
1725
|
const labelled = isEndpoint && group.label !== null;
|
|
1815
|
-
const basePriority = labelled ? TRACE_ENDPOINT_LABEL_PRIORITY : point2.basePriority;
|
|
1816
1726
|
diff.pointUpdates.push({
|
|
1817
1727
|
id,
|
|
1818
1728
|
addOrUpdateProperties: [
|
|
1819
1729
|
{ key: "pointRadius", value: isEndpoint ? point2.endpointRadius : TRACE_POINT_RADIUS },
|
|
1820
1730
|
{ key: "name", value: labelled ? group.label : point2.name },
|
|
1821
1731
|
{ key: "isTraceLabel", value: labelled },
|
|
1822
|
-
{ key: "_labelPriority", value:
|
|
1732
|
+
{ key: "_labelPriority", value: labelled ? TRACE_ENDPOINT_LABEL_PRIORITY : point2.basePriority }
|
|
1823
1733
|
]
|
|
1824
1734
|
});
|
|
1825
|
-
diff.basePriorities.push([id, basePriority]);
|
|
1826
1735
|
}
|
|
1827
1736
|
function diffConsecutivePairs(prev, next, onRemove, onAdd) {
|
|
1828
1737
|
let i = 0;
|
|
@@ -1844,7 +1753,7 @@ function diffConsecutivePairs(prev, next, onRemove, onAdd) {
|
|
|
1844
1753
|
}
|
|
1845
1754
|
}
|
|
1846
1755
|
}
|
|
1847
|
-
function applyTraceTimelineDiff(diff,
|
|
1756
|
+
function applyTraceTimelineDiff(diff, pointSource, segmentSource) {
|
|
1848
1757
|
try {
|
|
1849
1758
|
if (diff.pointUpdates.length > 0) pointSource.updateData({ update: diff.pointUpdates });
|
|
1850
1759
|
if (diff.segmentAdd.length > 0 || diff.segmentRemove.length > 0) {
|
|
@@ -1854,9 +1763,9 @@ function applyTraceTimelineDiff(diff, paint, pointSource, segmentSource) {
|
|
|
1854
1763
|
console.error("Trace timeline fast path failed; falling back to the full sync:", error);
|
|
1855
1764
|
return false;
|
|
1856
1765
|
}
|
|
1857
|
-
diff.basePriorities.forEach(([id, priority]) => paint.basePriorityById.set(id, priority));
|
|
1858
1766
|
return true;
|
|
1859
1767
|
}
|
|
1768
|
+
const DEFAULT_LABEL_PRIORITY = 100;
|
|
1860
1769
|
const RENDER_PASSTHROUGH_KEYS = ["_dvl_h3"];
|
|
1861
1770
|
const ANNOTATION_PASSTHROUGH_KEYS = [
|
|
1862
1771
|
"kind",
|
|
@@ -1964,7 +1873,6 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
1964
1873
|
});
|
|
1965
1874
|
}
|
|
1966
1875
|
}
|
|
1967
|
-
const isFeatureSelected = ctx.selectionEnabled && ctx.selectedIds.has(featureId) ? 1 : 0;
|
|
1968
1876
|
let nonTracePriority = DEFAULT_LABEL_PRIORITY;
|
|
1969
1877
|
if (((_l = f.properties) == null ? void 0 : _l.kind) === "text") {
|
|
1970
1878
|
nonTracePriority = ((_m = f.properties) == null ? void 0 : _m.fontWeight) === "bold" ? 8 : 10;
|
|
@@ -1977,8 +1885,7 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
1977
1885
|
}
|
|
1978
1886
|
nonTracePriority = DEFAULT_LABEL_PRIORITY + Math.abs(h) % 1e3;
|
|
1979
1887
|
}
|
|
1980
|
-
const
|
|
1981
|
-
const labelPriority = isFeatureSelected ? 0 : basePriority;
|
|
1888
|
+
const labelPriority = traceLabel ? TRACE_ENDPOINT_LABEL_PRIORITY : nonTracePriority;
|
|
1982
1889
|
const visibleStrokeOpacity = hideFlatFor3DOnly ? 0 : baseOpacity;
|
|
1983
1890
|
const visibleFillOpacity = hideFlatFor3DOnly ? 0 : ((_n = f.properties) == null ? void 0 : _n["fill-opacity"]) ?? DEFAULT_VISIBLE_FILL_OPACITY;
|
|
1984
1891
|
return {
|
|
@@ -1992,7 +1899,6 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
1992
1899
|
// Override with computed visual properties
|
|
1993
1900
|
id: featureId,
|
|
1994
1901
|
name: labelText,
|
|
1995
|
-
isSelected: isFeatureSelected,
|
|
1996
1902
|
isHiddenByHeatmap: hideByHeatmap ? 1 : 0,
|
|
1997
1903
|
isHiddenByCluster: hideByCluster ? 1 : 0,
|
|
1998
1904
|
isTracePoint: isTracePoint ? true : false,
|
|
@@ -2012,8 +1918,6 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
2012
1918
|
},
|
|
2013
1919
|
paint: {
|
|
2014
1920
|
featureId,
|
|
2015
|
-
basePriority,
|
|
2016
|
-
selected: isFeatureSelected === 1,
|
|
2017
1921
|
visibleStrokeOpacity,
|
|
2018
1922
|
visibleFillOpacity,
|
|
2019
1923
|
timelineHidden: !isTimelineVisible
|
|
@@ -2068,15 +1972,7 @@ async function runShardPass(input) {
|
|
|
2068
1972
|
var _a2;
|
|
2069
1973
|
const styled = styleFeatureForPaint(f, layer, ctx, true);
|
|
2070
1974
|
const p = styled.paint;
|
|
2071
|
-
recordPaintedFeature(
|
|
2072
|
-
cache2,
|
|
2073
|
-
p.featureId,
|
|
2074
|
-
p.basePriority,
|
|
2075
|
-
p.selected,
|
|
2076
|
-
p.visibleStrokeOpacity,
|
|
2077
|
-
p.visibleFillOpacity,
|
|
2078
|
-
p.timelineHidden
|
|
2079
|
-
);
|
|
1975
|
+
recordPaintedFeature(cache2, p.featureId, p.visibleStrokeOpacity, p.visibleFillOpacity, p.timelineHidden);
|
|
2080
1976
|
if (((_a2 = styled.feature.properties) == null ? void 0 : _a2.kind) === "arrow" && styled.feature.geometry.type === "LineString") {
|
|
2081
1977
|
shardArrows.push(styled.feature);
|
|
2082
1978
|
}
|
|
@@ -2637,6 +2533,148 @@ function useToast() {
|
|
|
2637
2533
|
};
|
|
2638
2534
|
return { toast };
|
|
2639
2535
|
}
|
|
2536
|
+
const DEFAULT_ENDPOINTS = {
|
|
2537
|
+
streetsStyle: "https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json",
|
|
2538
|
+
darkStyle: "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",
|
|
2539
|
+
satelliteTiles: ["https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"],
|
|
2540
|
+
satelliteAttribution: "Esri, Maxar, Earthstar Geographics",
|
|
2541
|
+
terrainTiles: ["https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"],
|
|
2542
|
+
geocodingUrl: "https://nominatim.openstreetmap.org/search",
|
|
2543
|
+
glyphsUrl: "/fonts/{fontstack}/{range}.pbf"
|
|
2544
|
+
};
|
|
2545
|
+
const BUILT_IN_NAMES = {
|
|
2546
|
+
streets: "Streets",
|
|
2547
|
+
satellite: "Satellite",
|
|
2548
|
+
dark: "Dark"
|
|
2549
|
+
};
|
|
2550
|
+
const isOff = (value) => value === false || value === null;
|
|
2551
|
+
const nonEmpty = (value) => typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
2552
|
+
const nonEmptyTiles = (tiles) => Array.isArray(tiles) ? tiles.filter((tile) => nonEmpty(tile) !== void 0) : [];
|
|
2553
|
+
function resolveVectorStyle(endpoint, defaultStyle) {
|
|
2554
|
+
if (isOff(endpoint)) return null;
|
|
2555
|
+
if (endpoint === void 0) return { style: defaultStyle };
|
|
2556
|
+
const style = nonEmpty(endpoint.style);
|
|
2557
|
+
return style ? { style, name: endpoint.name } : null;
|
|
2558
|
+
}
|
|
2559
|
+
function resolveGeocoder(endpoint) {
|
|
2560
|
+
if (isOff(endpoint)) return null;
|
|
2561
|
+
if (endpoint === void 0) return { url: DEFAULT_ENDPOINTS.geocodingUrl };
|
|
2562
|
+
if ("provider" in endpoint) return typeof endpoint.provider === "function" ? { provider: endpoint.provider } : null;
|
|
2563
|
+
const url = nonEmpty(endpoint.url);
|
|
2564
|
+
return url ? { url } : null;
|
|
2565
|
+
}
|
|
2566
|
+
function resolveEndpoints(endpoints) {
|
|
2567
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2568
|
+
const e = endpoints ?? {};
|
|
2569
|
+
const streets = resolveVectorStyle(e.streets, DEFAULT_ENDPOINTS.streetsStyle);
|
|
2570
|
+
const dark = resolveVectorStyle(e.dark, DEFAULT_ENDPOINTS.darkStyle);
|
|
2571
|
+
let satellite = null;
|
|
2572
|
+
let satelliteName;
|
|
2573
|
+
if (!isOff(e.satellite)) {
|
|
2574
|
+
const tiles = e.satellite === void 0 ? [...DEFAULT_ENDPOINTS.satelliteTiles] : nonEmptyTiles(e.satellite.tiles);
|
|
2575
|
+
if (tiles.length > 0) {
|
|
2576
|
+
satellite = {
|
|
2577
|
+
tiles,
|
|
2578
|
+
tileSize: ((_a = e.satellite) == null ? void 0 : _a.tileSize) ?? 256,
|
|
2579
|
+
minzoom: ((_b = e.satellite) == null ? void 0 : _b.minzoom) ?? 0,
|
|
2580
|
+
maxzoom: ((_c = e.satellite) == null ? void 0 : _c.maxzoom) ?? 22,
|
|
2581
|
+
attribution: e.satellite === void 0 ? DEFAULT_ENDPOINTS.satelliteAttribution : e.satellite.attribution ?? ""
|
|
2582
|
+
};
|
|
2583
|
+
satelliteName = (_d = e.satellite) == null ? void 0 : _d.name;
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
let terrain = null;
|
|
2587
|
+
if (!isOff(e.terrain)) {
|
|
2588
|
+
const tiles = e.terrain === void 0 ? [...DEFAULT_ENDPOINTS.terrainTiles] : nonEmptyTiles(e.terrain.tiles);
|
|
2589
|
+
if (tiles.length > 0) {
|
|
2590
|
+
terrain = {
|
|
2591
|
+
tiles,
|
|
2592
|
+
encoding: ((_e = e.terrain) == null ? void 0 : _e.encoding) ?? "terrarium",
|
|
2593
|
+
tileSize: ((_f = e.terrain) == null ? void 0 : _f.tileSize) ?? 256,
|
|
2594
|
+
minzoom: ((_g = e.terrain) == null ? void 0 : _g.minzoom) ?? 0,
|
|
2595
|
+
maxzoom: ((_h = e.terrain) == null ? void 0 : _h.maxzoom) ?? 15,
|
|
2596
|
+
attribution: ((_i = e.terrain) == null ? void 0 : _i.attribution) ?? ""
|
|
2597
|
+
};
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
const glyphs = e.glyphs;
|
|
2601
|
+
const adoptStyleGlyphs = glyphs === "from-style";
|
|
2602
|
+
const glyphsUrl = typeof glyphs === "object" && glyphs !== null && nonEmpty(glyphs.url) || DEFAULT_ENDPOINTS.glyphsUrl;
|
|
2603
|
+
const builtInBasemaps = [];
|
|
2604
|
+
if (streets) builtInBasemaps.push({ id: "streets", name: streets.name ?? BUILT_IN_NAMES.streets });
|
|
2605
|
+
if (satellite) builtInBasemaps.push({ id: "satellite", name: satelliteName ?? BUILT_IN_NAMES.satellite });
|
|
2606
|
+
if (dark) builtInBasemaps.push({ id: "dark", name: dark.name ?? BUILT_IN_NAMES.dark });
|
|
2607
|
+
return {
|
|
2608
|
+
vectorStyles: {
|
|
2609
|
+
...streets ? { streets: streets.style } : {},
|
|
2610
|
+
...dark ? { dark: dark.style } : {}
|
|
2611
|
+
},
|
|
2612
|
+
satellite,
|
|
2613
|
+
terrain,
|
|
2614
|
+
glyphsUrl,
|
|
2615
|
+
adoptStyleGlyphs,
|
|
2616
|
+
builtInBasemaps
|
|
2617
|
+
};
|
|
2618
|
+
}
|
|
2619
|
+
function builtInStyleUrl(resolved, id) {
|
|
2620
|
+
if (id === "streets") return resolved.vectorStyles.streets;
|
|
2621
|
+
if (id === "dark") return resolved.vectorStyles.dark;
|
|
2622
|
+
return void 0;
|
|
2623
|
+
}
|
|
2624
|
+
function isBuiltInBasemapEnabled(resolved, id) {
|
|
2625
|
+
return resolved.builtInBasemaps.some((basemap) => basemap.id === id);
|
|
2626
|
+
}
|
|
2627
|
+
const BUILT_IN_IDS = ["streets", "satellite", "dark"];
|
|
2628
|
+
function initialBasemapId(resolved, requested) {
|
|
2629
|
+
var _a;
|
|
2630
|
+
if (!BUILT_IN_IDS.includes(requested) || isBuiltInBasemapEnabled(resolved, requested)) return requested;
|
|
2631
|
+
return ((_a = resolved.builtInBasemaps[0]) == null ? void 0 : _a.id) ?? requested;
|
|
2632
|
+
}
|
|
2633
|
+
function createBaseStyle(resolved) {
|
|
2634
|
+
const sources = {};
|
|
2635
|
+
const layers = [
|
|
2636
|
+
{ id: "background", type: "background", paint: { "background-color": "#f0f0f0" } }
|
|
2637
|
+
];
|
|
2638
|
+
if (resolved.satellite) {
|
|
2639
|
+
sources["satellite-tiles"] = {
|
|
2640
|
+
type: "raster",
|
|
2641
|
+
tiles: resolved.satellite.tiles,
|
|
2642
|
+
tileSize: resolved.satellite.tileSize,
|
|
2643
|
+
minzoom: resolved.satellite.minzoom,
|
|
2644
|
+
maxzoom: resolved.satellite.maxzoom,
|
|
2645
|
+
attribution: resolved.satellite.attribution
|
|
2646
|
+
};
|
|
2647
|
+
layers.push({
|
|
2648
|
+
id: "satellite-layer",
|
|
2649
|
+
type: "raster",
|
|
2650
|
+
source: "satellite-tiles",
|
|
2651
|
+
minzoom: 0,
|
|
2652
|
+
maxzoom: 22,
|
|
2653
|
+
layout: { visibility: "none" }
|
|
2654
|
+
});
|
|
2655
|
+
}
|
|
2656
|
+
if (resolved.terrain) {
|
|
2657
|
+
sources["terrain-dem"] = {
|
|
2658
|
+
type: "raster-dem",
|
|
2659
|
+
tiles: resolved.terrain.tiles,
|
|
2660
|
+
tileSize: resolved.terrain.tileSize,
|
|
2661
|
+
minzoom: resolved.terrain.minzoom,
|
|
2662
|
+
maxzoom: resolved.terrain.maxzoom,
|
|
2663
|
+
encoding: resolved.terrain.encoding,
|
|
2664
|
+
attribution: resolved.terrain.attribution
|
|
2665
|
+
};
|
|
2666
|
+
}
|
|
2667
|
+
return { version: 8, sources, layers, glyphs: resolved.glyphsUrl };
|
|
2668
|
+
}
|
|
2669
|
+
async function geocodeAddress(geocoder, query, fetchImpl = fetch) {
|
|
2670
|
+
if ("provider" in geocoder) return geocoder.provider(query);
|
|
2671
|
+
const response = await fetchImpl(`${geocoder.url}?format=json&q=${encodeURIComponent(query)}&limit=1`);
|
|
2672
|
+
if (!response.ok) throw new Error("Search failed");
|
|
2673
|
+
const results = await response.json();
|
|
2674
|
+
if (!Array.isArray(results) || results.length === 0) return null;
|
|
2675
|
+
const { lon, lat, display_name } = results[0];
|
|
2676
|
+
return { lon: parseFloat(lon), lat: parseFloat(lat), displayName: display_name };
|
|
2677
|
+
}
|
|
2640
2678
|
function ToolButton({ mode, activeMode, onModeChange, icon, label, shortcut, disabled, showShortcutHint = true }) {
|
|
2641
2679
|
const isActive = activeMode === mode;
|
|
2642
2680
|
const handleClick = () => {
|
|
@@ -2714,8 +2752,7 @@ function DrawingToolbar({
|
|
|
2714
2752
|
onClearFilter,
|
|
2715
2753
|
onFilterActiveChange,
|
|
2716
2754
|
onSearchEngineRequest,
|
|
2717
|
-
|
|
2718
|
-
geocoderProvider,
|
|
2755
|
+
geocoder,
|
|
2719
2756
|
showShortcutHints = true,
|
|
2720
2757
|
expandSelectionTools = false,
|
|
2721
2758
|
showFilterTool = false,
|
|
@@ -2729,6 +2766,7 @@ function DrawingToolbar({
|
|
|
2729
2766
|
const [goToLng, setGoToLng] = useState("");
|
|
2730
2767
|
const [goToAddress, setGoToAddress] = useState("");
|
|
2731
2768
|
const [isSearching, setIsSearching] = useState(false);
|
|
2769
|
+
const resolvedGeocoder = useMemo(() => resolveGeocoder(geocoder), [geocoder]);
|
|
2732
2770
|
const [filterActive, setFilterActive] = useState(false);
|
|
2733
2771
|
const [isCompact, setIsCompact] = useState(false);
|
|
2734
2772
|
const [featureSearchOpen, setFeatureSearchOpen] = useState(false);
|
|
@@ -2861,27 +2899,10 @@ function DrawingToolbar({
|
|
|
2861
2899
|
setGoToLng("");
|
|
2862
2900
|
};
|
|
2863
2901
|
const handleAddressSearch = async () => {
|
|
2864
|
-
if (!goToAddress.trim()) return;
|
|
2902
|
+
if (!resolvedGeocoder || !goToAddress.trim()) return;
|
|
2865
2903
|
setIsSearching(true);
|
|
2866
2904
|
try {
|
|
2867
|
-
|
|
2868
|
-
if (geocoderProvider) {
|
|
2869
|
-
result = await geocoderProvider(goToAddress.trim());
|
|
2870
|
-
} else {
|
|
2871
|
-
const response = await fetch(
|
|
2872
|
-
`${geocodingUrl}?format=json&q=${encodeURIComponent(goToAddress)}&limit=1`
|
|
2873
|
-
);
|
|
2874
|
-
if (!response.ok) throw new Error("Search failed");
|
|
2875
|
-
const results = await response.json();
|
|
2876
|
-
if (results.length > 0) {
|
|
2877
|
-
const { lon, lat, display_name } = results[0];
|
|
2878
|
-
result = {
|
|
2879
|
-
lon: parseFloat(lon),
|
|
2880
|
-
lat: parseFloat(lat),
|
|
2881
|
-
displayName: display_name
|
|
2882
|
-
};
|
|
2883
|
-
}
|
|
2884
|
-
}
|
|
2905
|
+
const result = await geocodeAddress(resolvedGeocoder, goToAddress.trim());
|
|
2885
2906
|
if (!result) {
|
|
2886
2907
|
toast({
|
|
2887
2908
|
title: "Location not found",
|
|
@@ -3652,41 +3673,43 @@ function DrawingToolbar({
|
|
|
3652
3673
|
/* @__PURE__ */ jsx(Navigation, { className: "w-3 h-3 text-muted-foreground" }),
|
|
3653
3674
|
/* @__PURE__ */ jsx("span", { className: "text-[10px] font-semibold uppercase tracking-wider text-muted-foreground", children: "Navigate To" })
|
|
3654
3675
|
] }),
|
|
3655
|
-
/* @__PURE__ */ jsxs(
|
|
3656
|
-
/* @__PURE__ */
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
/* @__PURE__ */
|
|
3688
|
-
|
|
3689
|
-
|
|
3676
|
+
resolvedGeocoder && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3677
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
3678
|
+
/* @__PURE__ */ jsx(
|
|
3679
|
+
Input,
|
|
3680
|
+
{
|
|
3681
|
+
placeholder: "Search address...",
|
|
3682
|
+
value: goToAddress,
|
|
3683
|
+
onChange: (e) => setGoToAddress(e.target.value),
|
|
3684
|
+
onKeyDown: (e) => {
|
|
3685
|
+
if (e.key === "Enter") handleAddressSearch();
|
|
3686
|
+
},
|
|
3687
|
+
disabled: isSearching,
|
|
3688
|
+
size: "small",
|
|
3689
|
+
prefix: /* @__PURE__ */ jsx(MapPin, { className: "w-3.5 h-3.5 opacity-50" }),
|
|
3690
|
+
allowClear: true,
|
|
3691
|
+
"data-testid": "input-goto-address"
|
|
3692
|
+
}
|
|
3693
|
+
),
|
|
3694
|
+
/* @__PURE__ */ jsx(
|
|
3695
|
+
Button,
|
|
3696
|
+
{
|
|
3697
|
+
type: "primary",
|
|
3698
|
+
size: "small",
|
|
3699
|
+
onClick: handleAddressSearch,
|
|
3700
|
+
disabled: isSearching || !goToAddress.trim(),
|
|
3701
|
+
className: "shrink-0",
|
|
3702
|
+
"data-testid": "button-search-address",
|
|
3703
|
+
icon: isSearching ? /* @__PURE__ */ jsx(Loader2, { className: "w-4 h-4 animate-spin" }) : void 0,
|
|
3704
|
+
children: isSearching ? "" : "Go"
|
|
3705
|
+
}
|
|
3706
|
+
)
|
|
3707
|
+
] }),
|
|
3708
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
3709
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 h-px bg-border" }),
|
|
3710
|
+
/* @__PURE__ */ jsx("span", { className: "text-[10px] text-muted-foreground shrink-0", children: "or coordinates" }),
|
|
3711
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 h-px bg-border" })
|
|
3712
|
+
] })
|
|
3690
3713
|
] }),
|
|
3691
3714
|
/* @__PURE__ */ jsxs("div", { className: "flex gap-2 items-end", children: [
|
|
3692
3715
|
/* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
@@ -3747,16 +3770,21 @@ function DrawingToolbar({
|
|
|
3747
3770
|
);
|
|
3748
3771
|
}
|
|
3749
3772
|
const BUILT_IN_BASEMAP_IDS = ["streets", "satellite", "dark"];
|
|
3750
|
-
const
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3773
|
+
const isBuiltInId = (id) => BUILT_IN_BASEMAP_IDS.includes(id);
|
|
3774
|
+
function customBasemapsWithoutBuiltIns(customBasemaps) {
|
|
3775
|
+
if (!customBasemaps) return void 0;
|
|
3776
|
+
const ignored = Object.keys(customBasemaps).filter(isBuiltInId);
|
|
3777
|
+
if (ignored.length === 0) return customBasemaps;
|
|
3778
|
+
console.warn(
|
|
3779
|
+
`[map-component] customBasemaps entries for built-in ids are ignored (${ignored.join(", ")}); configure them through the endpoints prop.`
|
|
3780
|
+
);
|
|
3781
|
+
return Object.fromEntries(Object.entries(customBasemaps).filter(([id]) => !isBuiltInId(id)));
|
|
3782
|
+
}
|
|
3783
|
+
function resolveBasemapChoices(order, customBasemaps, builtIns) {
|
|
3756
3784
|
const describe = (id) => {
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3785
|
+
const builtIn = builtIns.find((entry) => entry.id === id);
|
|
3786
|
+
if (builtIn) return { id, name: builtIn.name, builtIn: true };
|
|
3787
|
+
if (isBuiltInId(id)) return void 0;
|
|
3760
3788
|
const custom = customBasemaps == null ? void 0 : customBasemaps[id];
|
|
3761
3789
|
if (!custom) return void 0;
|
|
3762
3790
|
return { id, name: custom.name || id, builtIn: false };
|
|
@@ -3764,13 +3792,8 @@ function resolveBasemapChoices(order, customBasemaps) {
|
|
|
3764
3792
|
if (order) {
|
|
3765
3793
|
return order.map(describe).filter((choice) => !!choice);
|
|
3766
3794
|
}
|
|
3767
|
-
const customIds = Object.keys(customBasemaps ?? {}).filter(
|
|
3768
|
-
|
|
3769
|
-
);
|
|
3770
|
-
return [
|
|
3771
|
-
...BUILT_IN_BASEMAP_IDS.map((id) => describe(id)),
|
|
3772
|
-
...customIds.map(describe).filter((choice) => !!choice)
|
|
3773
|
-
];
|
|
3795
|
+
const customIds = Object.keys(customBasemaps ?? {}).filter((id) => !isBuiltInId(id));
|
|
3796
|
+
return [...builtIns.map((entry) => entry.id), ...customIds].map(describe).filter((choice) => !!choice);
|
|
3774
3797
|
}
|
|
3775
3798
|
const PRESET_COLORS$1 = [
|
|
3776
3799
|
"#3b82f6",
|
|
@@ -5372,10 +5395,10 @@ const RECORD_EXCLUDE_KEYS = /* @__PURE__ */ new Set([
|
|
|
5372
5395
|
// NOTE: 'description' intentionally NOT excluded — we surface it as a regular
|
|
5373
5396
|
// property row instead of giving it its own labelled section.
|
|
5374
5397
|
]);
|
|
5375
|
-
function buildKeyExclusionPredicate(
|
|
5376
|
-
const lowered = new Set(Array.from(
|
|
5398
|
+
function buildKeyExclusionPredicate(set2) {
|
|
5399
|
+
const lowered = new Set(Array.from(set2, (k) => k.toLowerCase()));
|
|
5377
5400
|
return (key) => {
|
|
5378
|
-
if (
|
|
5401
|
+
if (set2.has(key)) return true;
|
|
5379
5402
|
const normalized = key.toLowerCase().replace(/^[^a-z0-9_-]+/, "");
|
|
5380
5403
|
return lowered.has(normalized);
|
|
5381
5404
|
};
|
|
@@ -6929,7 +6952,7 @@ function computeHistogramBins(features, minDate, maxDate, binCount = 50) {
|
|
|
6929
6952
|
});
|
|
6930
6953
|
return bins;
|
|
6931
6954
|
}
|
|
6932
|
-
const timelineStoreInitializer = (
|
|
6955
|
+
const timelineStoreInitializer = (set2, get) => ({
|
|
6933
6956
|
isEnabled: false,
|
|
6934
6957
|
hasTemporalData: false,
|
|
6935
6958
|
temporalFeatures: [],
|
|
@@ -6944,13 +6967,13 @@ const timelineStoreInitializer = (set, get) => ({
|
|
|
6944
6967
|
setEnabled: (enabled) => {
|
|
6945
6968
|
if (enabled) {
|
|
6946
6969
|
const state = get();
|
|
6947
|
-
|
|
6970
|
+
set2({
|
|
6948
6971
|
isEnabled: true,
|
|
6949
6972
|
rangeStart: state.globalMinDate,
|
|
6950
6973
|
rangeEnd: state.globalMaxDate
|
|
6951
6974
|
});
|
|
6952
6975
|
} else {
|
|
6953
|
-
|
|
6976
|
+
set2({ isEnabled: false, isPlaying: false });
|
|
6954
6977
|
}
|
|
6955
6978
|
},
|
|
6956
6979
|
setTemporalFeatures: (features, untimedIds) => {
|
|
@@ -6959,7 +6982,7 @@ const timelineStoreInitializer = (set, get) => ({
|
|
|
6959
6982
|
const state = get();
|
|
6960
6983
|
if (timedFeatures.length === 0) {
|
|
6961
6984
|
if (!state.hasTemporalData && state.temporalFeatures.length === 0) return;
|
|
6962
|
-
|
|
6985
|
+
set2({
|
|
6963
6986
|
hasTemporalData: false,
|
|
6964
6987
|
temporalFeatures: [],
|
|
6965
6988
|
untimedFeatureIds: untimedIds,
|
|
@@ -6986,7 +7009,7 @@ const timelineStoreInitializer = (set, get) => ({
|
|
|
6986
7009
|
const sameUntimed = state.untimedFeatureIds.length === untimedIds.length && untimedIds.every((id, i) => id === state.untimedFeatureIds[i]);
|
|
6987
7010
|
if (sameFeatureIds && sameDates && sameUntimed && state.hasTemporalData) return;
|
|
6988
7011
|
const histogramBins = minDate && maxDate ? computeHistogramBins(timedFeatures, minDate, maxDate) : [];
|
|
6989
|
-
|
|
7012
|
+
set2({
|
|
6990
7013
|
hasTemporalData: true,
|
|
6991
7014
|
temporalFeatures: timedFeatures,
|
|
6992
7015
|
untimedFeatureIds: untimedIds,
|
|
@@ -6997,9 +7020,9 @@ const timelineStoreInitializer = (set, get) => ({
|
|
|
6997
7020
|
histogramBins
|
|
6998
7021
|
});
|
|
6999
7022
|
},
|
|
7000
|
-
setRange: (start, end) =>
|
|
7001
|
-
setPlaying: (playing) =>
|
|
7002
|
-
setPlaybackSpeed: (speed) =>
|
|
7023
|
+
setRange: (start, end) => set2({ rangeStart: start, rangeEnd: end }),
|
|
7024
|
+
setPlaying: (playing) => set2({ isPlaying: playing }),
|
|
7025
|
+
setPlaybackSpeed: (speed) => set2({ playbackSpeed: speed }),
|
|
7003
7026
|
advancePlayhead: () => {
|
|
7004
7027
|
const state = get();
|
|
7005
7028
|
if (!state.globalMinDate || !state.globalMaxDate || !state.rangeStart) {
|
|
@@ -7010,20 +7033,20 @@ const timelineStoreInitializer = (set, get) => ({
|
|
|
7010
7033
|
const newStart = new Date(state.rangeStart.getTime() + stepSize);
|
|
7011
7034
|
const newEnd = state.rangeEnd ? new Date(state.rangeEnd.getTime() + stepSize) : null;
|
|
7012
7035
|
if (newStart >= state.globalMaxDate) {
|
|
7013
|
-
|
|
7036
|
+
set2({
|
|
7014
7037
|
isPlaying: false,
|
|
7015
7038
|
rangeStart: state.globalMinDate,
|
|
7016
7039
|
rangeEnd: state.globalMaxDate
|
|
7017
7040
|
});
|
|
7018
7041
|
return false;
|
|
7019
7042
|
}
|
|
7020
|
-
|
|
7043
|
+
set2({
|
|
7021
7044
|
rangeStart: newStart,
|
|
7022
7045
|
rangeEnd: newEnd && newEnd <= state.globalMaxDate ? newEnd : state.globalMaxDate
|
|
7023
7046
|
});
|
|
7024
7047
|
return true;
|
|
7025
7048
|
},
|
|
7026
|
-
reset: () =>
|
|
7049
|
+
reset: () => set2({
|
|
7027
7050
|
isEnabled: false,
|
|
7028
7051
|
hasTemporalData: false,
|
|
7029
7052
|
temporalFeatures: [],
|
|
@@ -7801,6 +7824,129 @@ function createRafCoalescer(run, scheduler = rafScheduler) {
|
|
|
7801
7824
|
}
|
|
7802
7825
|
};
|
|
7803
7826
|
}
|
|
7827
|
+
const EMPTY = /* @__PURE__ */ new Set();
|
|
7828
|
+
function isLive(host, entry) {
|
|
7829
|
+
return host.source(entry.sourceId) === entry.handle;
|
|
7830
|
+
}
|
|
7831
|
+
function remove(host, entry, id) {
|
|
7832
|
+
if (!isLive(host, entry)) return false;
|
|
7833
|
+
host.removeFeatureState(entry.sourceId, id);
|
|
7834
|
+
return true;
|
|
7835
|
+
}
|
|
7836
|
+
function set(host, sourceId, id) {
|
|
7837
|
+
const handle = host.source(sourceId);
|
|
7838
|
+
if (!handle) return null;
|
|
7839
|
+
host.setFeatureState(sourceId, id, SELECTED_STATE);
|
|
7840
|
+
return { sourceId, handle };
|
|
7841
|
+
}
|
|
7842
|
+
function setAll(host, sourceIds, id) {
|
|
7843
|
+
const done = [];
|
|
7844
|
+
sourceIds.forEach((sourceId) => {
|
|
7845
|
+
const entry = set(host, sourceId, id);
|
|
7846
|
+
if (entry) done.push(entry);
|
|
7847
|
+
});
|
|
7848
|
+
return done;
|
|
7849
|
+
}
|
|
7850
|
+
function place(applied, id, sources, host) {
|
|
7851
|
+
const done = setAll(host, sources, id);
|
|
7852
|
+
if (done.length > 0) applied.set(id, done);
|
|
7853
|
+
return done.length;
|
|
7854
|
+
}
|
|
7855
|
+
function applySelectionState(applied, next, gate, locate, host) {
|
|
7856
|
+
const target = gate ? next : EMPTY;
|
|
7857
|
+
let setCount = 0;
|
|
7858
|
+
let removed = 0;
|
|
7859
|
+
const gone = [];
|
|
7860
|
+
applied.forEach((_sources, id) => {
|
|
7861
|
+
if (!target.has(id)) gone.push(id);
|
|
7862
|
+
});
|
|
7863
|
+
gone.forEach((id) => {
|
|
7864
|
+
(applied.get(id) ?? []).forEach((entry) => {
|
|
7865
|
+
if (remove(host, entry, id)) removed++;
|
|
7866
|
+
});
|
|
7867
|
+
applied.delete(id);
|
|
7868
|
+
});
|
|
7869
|
+
target.forEach((id) => {
|
|
7870
|
+
if (applied.has(id)) return;
|
|
7871
|
+
setCount += place(applied, id, locate(id), host);
|
|
7872
|
+
});
|
|
7873
|
+
return { set: setCount, removed };
|
|
7874
|
+
}
|
|
7875
|
+
function reconcileSelectionSources(applied, locate, host) {
|
|
7876
|
+
let moved = 0;
|
|
7877
|
+
let pruned = 0;
|
|
7878
|
+
const changes = [];
|
|
7879
|
+
applied.forEach((have, id) => {
|
|
7880
|
+
const want = locate(id);
|
|
7881
|
+
const live = have.filter((entry) => isLive(host, entry));
|
|
7882
|
+
const same = want.length > 0 && live.length === have.length && want.every((sourceId) => live.some((entry) => entry.sourceId === sourceId));
|
|
7883
|
+
if (!same) changes.push({ id, have, live, want });
|
|
7884
|
+
});
|
|
7885
|
+
changes.forEach(({ id, have, live, want }) => {
|
|
7886
|
+
if (want.length === 0) {
|
|
7887
|
+
have.forEach((entry) => remove(host, entry, id));
|
|
7888
|
+
applied.delete(id);
|
|
7889
|
+
pruned++;
|
|
7890
|
+
return;
|
|
7891
|
+
}
|
|
7892
|
+
const missing = want.filter((sourceId) => !live.some((entry) => entry.sourceId === sourceId));
|
|
7893
|
+
const gained = setAll(host, missing, id);
|
|
7894
|
+
const now = [...live, ...gained];
|
|
7895
|
+
if (now.length > 0) applied.set(id, now);
|
|
7896
|
+
else applied.delete(id);
|
|
7897
|
+
if (gained.length > 0) moved++;
|
|
7898
|
+
});
|
|
7899
|
+
return { moved, pruned };
|
|
7900
|
+
}
|
|
7901
|
+
function createLocatorCache() {
|
|
7902
|
+
return /* @__PURE__ */ new WeakMap();
|
|
7903
|
+
}
|
|
7904
|
+
function indexOfIds(features, cache2) {
|
|
7905
|
+
const cached = cache2.get(features);
|
|
7906
|
+
if (cached) return cached;
|
|
7907
|
+
const index = { first: /* @__PURE__ */ new Map(), repeats: /* @__PURE__ */ new Map() };
|
|
7908
|
+
for (let i = 0; i < features.length; i++) {
|
|
7909
|
+
const id = features[i].id;
|
|
7910
|
+
if (id === void 0 || id === null) continue;
|
|
7911
|
+
const key = String(id);
|
|
7912
|
+
if (!index.first.has(key)) index.first.set(key, i);
|
|
7913
|
+
else {
|
|
7914
|
+
const more = index.repeats.get(key);
|
|
7915
|
+
if (more) more.push(i);
|
|
7916
|
+
else index.repeats.set(key, [i]);
|
|
7917
|
+
}
|
|
7918
|
+
}
|
|
7919
|
+
cache2.set(features, index);
|
|
7920
|
+
return index;
|
|
7921
|
+
}
|
|
7922
|
+
function forEachIndex(index, id, visit) {
|
|
7923
|
+
var _a;
|
|
7924
|
+
const at = index.first.get(id);
|
|
7925
|
+
if (at === void 0) return;
|
|
7926
|
+
visit(at);
|
|
7927
|
+
(_a = index.repeats.get(id)) == null ? void 0 : _a.forEach(visit);
|
|
7928
|
+
}
|
|
7929
|
+
function locateFeatureHolders(id, readOnly, cache2) {
|
|
7930
|
+
const holders = [];
|
|
7931
|
+
readOnly.forEach((features, layerId) => {
|
|
7932
|
+
forEachIndex(indexOfIds(features, cache2), id, (at) => holders.push({ layerId, feature: features[at] }));
|
|
7933
|
+
});
|
|
7934
|
+
return holders;
|
|
7935
|
+
}
|
|
7936
|
+
function locateFeatureSources(id, inputs, cache2) {
|
|
7937
|
+
const sources = [];
|
|
7938
|
+
const add = (sourceId) => {
|
|
7939
|
+
if (!sources.includes(sourceId)) sources.push(sourceId);
|
|
7940
|
+
};
|
|
7941
|
+
inputs.readOnly.forEach((features, layerId) => {
|
|
7942
|
+
const sharded = inputs.shardedLayerIds.has(layerId);
|
|
7943
|
+
forEachIndex(indexOfIds(features, cache2), id, (at) => {
|
|
7944
|
+
add(sharded ? shardSourceId(layerId, Math.floor(at / inputs.shardSize)) : SHARED_SOURCE_ID);
|
|
7945
|
+
});
|
|
7946
|
+
});
|
|
7947
|
+
if (sources.length === 0) add(SHARED_SOURCE_ID);
|
|
7948
|
+
return sources;
|
|
7949
|
+
}
|
|
7804
7950
|
function deepClone(value) {
|
|
7805
7951
|
try {
|
|
7806
7952
|
return structuredClone(value);
|
|
@@ -8063,6 +8209,93 @@ function hitTestSelection(featureGroups, selectionPolygon, options) {
|
|
|
8063
8209
|
mapPerfLog("hit-test", "selection gesture", { visited, total, selected: selectedIds.length });
|
|
8064
8210
|
return selectedIds;
|
|
8065
8211
|
}
|
|
8212
|
+
const SELECTION_OVERLAY_SOURCE_ID = "selection-overlay";
|
|
8213
|
+
const SELECTION_OVERLAY_LAYER_IDS = {
|
|
8214
|
+
iconRing: "selection-overlay-icon-ring",
|
|
8215
|
+
line: "selection-overlay-line",
|
|
8216
|
+
polygon: "selection-overlay-polygon",
|
|
8217
|
+
label: "selection-overlay-label"
|
|
8218
|
+
};
|
|
8219
|
+
function buildSelectionOverlayStack() {
|
|
8220
|
+
const source = SELECTION_OVERLAY_SOURCE_ID;
|
|
8221
|
+
return [
|
|
8222
|
+
{
|
|
8223
|
+
id: SELECTION_OVERLAY_LAYER_IDS.iconRing,
|
|
8224
|
+
type: "circle",
|
|
8225
|
+
source,
|
|
8226
|
+
filter: ["all", ["==", "$type", "Point"], ["!=", "icon", ""], ["!=", "isHiddenByHeatmap", 1]],
|
|
8227
|
+
paint: {
|
|
8228
|
+
"circle-color": "transparent",
|
|
8229
|
+
"circle-radius": ["/", ["coalesce", ["get", "iconSize"], 24], 1.6],
|
|
8230
|
+
"circle-stroke-color": SELECTION_COLOR,
|
|
8231
|
+
"circle-stroke-width": 3,
|
|
8232
|
+
"circle-stroke-opacity": 1
|
|
8233
|
+
}
|
|
8234
|
+
},
|
|
8235
|
+
{
|
|
8236
|
+
id: SELECTION_OVERLAY_LAYER_IDS.line,
|
|
8237
|
+
type: "line",
|
|
8238
|
+
source,
|
|
8239
|
+
filter: ["==", "$type", "LineString"],
|
|
8240
|
+
paint: {
|
|
8241
|
+
"line-color": SELECTION_COLOR,
|
|
8242
|
+
"line-width": ["+", ["get", "stroke-width"], 4],
|
|
8243
|
+
"line-dasharray": [4, 2]
|
|
8244
|
+
}
|
|
8245
|
+
},
|
|
8246
|
+
{
|
|
8247
|
+
id: SELECTION_OVERLAY_LAYER_IDS.polygon,
|
|
8248
|
+
type: "line",
|
|
8249
|
+
source,
|
|
8250
|
+
filter: ["==", "$type", "Polygon"],
|
|
8251
|
+
paint: {
|
|
8252
|
+
"line-color": SELECTION_COLOR,
|
|
8253
|
+
"line-width": 4,
|
|
8254
|
+
"line-dasharray": [4, 2]
|
|
8255
|
+
}
|
|
8256
|
+
},
|
|
8257
|
+
{
|
|
8258
|
+
id: SELECTION_OVERLAY_LAYER_IDS.label,
|
|
8259
|
+
type: "symbol",
|
|
8260
|
+
source,
|
|
8261
|
+
layout: {
|
|
8262
|
+
...buildCustomLabelLayout(),
|
|
8263
|
+
// Never hidden by the auto-label density cap, which only flips the
|
|
8264
|
+
// unpinned base layer: with base labels off, the selected ones stay.
|
|
8265
|
+
visibility: "visible",
|
|
8266
|
+
// Full collision; topmost, so placed first (see the module comment):
|
|
8267
|
+
// selected labels thin among themselves and win against every other.
|
|
8268
|
+
"text-allow-overlap": false,
|
|
8269
|
+
"text-ignore-placement": false,
|
|
8270
|
+
"text-optional": true,
|
|
8271
|
+
// Same ranking as the base layers, so which selected label wins a
|
|
8272
|
+
// crowded spot is stable across repaints.
|
|
8273
|
+
"symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100]
|
|
8274
|
+
},
|
|
8275
|
+
paint: buildCustomLabelPaint()
|
|
8276
|
+
}
|
|
8277
|
+
];
|
|
8278
|
+
}
|
|
8279
|
+
function overlayTimelineInputs(ids, visible) {
|
|
8280
|
+
const hidden = /* @__PURE__ */ new Set();
|
|
8281
|
+
if (visible !== null) ids.forEach((id) => {
|
|
8282
|
+
if (!visible.has(id)) hidden.add(id);
|
|
8283
|
+
});
|
|
8284
|
+
return { ids, hidden };
|
|
8285
|
+
}
|
|
8286
|
+
function sameIds(a, b) {
|
|
8287
|
+
return a.size === b.size && Array.from(a).every((id) => b.has(id));
|
|
8288
|
+
}
|
|
8289
|
+
function sameOverlayTimelineInputs(a, b) {
|
|
8290
|
+
return sameIds(a.ids, b.ids) && sameIds(a.hidden, b.hidden);
|
|
8291
|
+
}
|
|
8292
|
+
function buildSelectionOverlayData(ids, styleFor) {
|
|
8293
|
+
const features = [];
|
|
8294
|
+
ids.forEach((id) => {
|
|
8295
|
+
styleFor(id).forEach((feature) => features.push(feature));
|
|
8296
|
+
});
|
|
8297
|
+
return { type: "FeatureCollection", features };
|
|
8298
|
+
}
|
|
8066
8299
|
function renderedFeatureId(f) {
|
|
8067
8300
|
var _a;
|
|
8068
8301
|
const fromProps = (_a = f.properties) == null ? void 0 : _a.id;
|
|
@@ -8592,6 +8825,8 @@ function ClusterPieManager(props) {
|
|
|
8592
8825
|
return null;
|
|
8593
8826
|
}
|
|
8594
8827
|
const EMPTY_ID_SET = /* @__PURE__ */ new Set();
|
|
8828
|
+
const EMPTY_SOURCES = [];
|
|
8829
|
+
const TOOLTIP_EXCLUDED_KEYS = ["stroke", "stroke-width", "stroke-opacity", "fill", "fill-opacity", "pointRadius", "kind", "meta:type", "circleCenter", "circleRadius", "icon", "iconSize", "pointIcon", "pointIconSize", "fontSize", "fontColor", "fontWeight", "arrowSize", "label", "entityType"];
|
|
8595
8830
|
const EMPTY_LABEL_MAP = /* @__PURE__ */ new Map();
|
|
8596
8831
|
function renderEmojiToCanvas(emoji, size = EMOJI_CANVAS_SIZE) {
|
|
8597
8832
|
const ratio = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
@@ -8792,53 +9027,16 @@ function extract3DFlightPaths(features) {
|
|
|
8792
9027
|
return paths;
|
|
8793
9028
|
}
|
|
8794
9029
|
const CAP_NOTICE_INTERVAL_MS = 5e3;
|
|
8795
|
-
const DEFAULT_LOCAL_GLYPHS_URL = "/fonts/{fontstack}/{range}.pbf";
|
|
8796
9030
|
function basemapInsertAnchor(map) {
|
|
8797
9031
|
if (map.getLayer("satellite-layer")) return "satellite-layer";
|
|
8798
9032
|
if (map.getLayer("custom-polygon-fill")) return "custom-polygon-fill";
|
|
8799
9033
|
return void 0;
|
|
8800
9034
|
}
|
|
8801
|
-
function
|
|
8802
|
-
const sources = {};
|
|
8803
|
-
const layers = [
|
|
8804
|
-
{
|
|
8805
|
-
id: "background",
|
|
8806
|
-
type: "background",
|
|
8807
|
-
paint: {
|
|
8808
|
-
"background-color": "#f0f0f0"
|
|
8809
|
-
}
|
|
8810
|
-
}
|
|
8811
|
-
];
|
|
8812
|
-
if (options.enableSatellite !== false) {
|
|
8813
|
-
sources["satellite-tiles"] = {
|
|
8814
|
-
type: "raster",
|
|
8815
|
-
tiles: ["https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"],
|
|
8816
|
-
tileSize: 256,
|
|
8817
|
-
attribution: "Esri, Maxar, Earthstar Geographics"
|
|
8818
|
-
};
|
|
8819
|
-
layers.push({
|
|
8820
|
-
id: "satellite-layer",
|
|
8821
|
-
type: "raster",
|
|
8822
|
-
source: "satellite-tiles",
|
|
8823
|
-
minzoom: 0,
|
|
8824
|
-
maxzoom: 22,
|
|
8825
|
-
layout: { visibility: "none" }
|
|
8826
|
-
});
|
|
8827
|
-
}
|
|
8828
|
-
if (options.enableTerrain !== false) {
|
|
8829
|
-
sources["terrain-dem"] = {
|
|
8830
|
-
type: "raster-dem",
|
|
8831
|
-
tiles: ["https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"],
|
|
8832
|
-
tileSize: 256,
|
|
8833
|
-
maxzoom: 15,
|
|
8834
|
-
encoding: "terrarium"
|
|
8835
|
-
};
|
|
8836
|
-
}
|
|
9035
|
+
function featureStateHostFor(m) {
|
|
8837
9036
|
return {
|
|
8838
|
-
|
|
8839
|
-
|
|
8840
|
-
|
|
8841
|
-
glyphs: options.glyphsUrl || DEFAULT_LOCAL_GLYPHS_URL
|
|
9037
|
+
setFeatureState: (source, id, state) => m.setFeatureState({ source, id }, state),
|
|
9038
|
+
removeFeatureState: (source, id) => m.removeFeatureState({ source, id }),
|
|
9039
|
+
source: (source) => m.getSource(source)
|
|
8842
9040
|
};
|
|
8843
9041
|
}
|
|
8844
9042
|
const BASEMAP_LAYER_PREFIXES = {
|
|
@@ -8846,10 +9044,6 @@ const BASEMAP_LAYER_PREFIXES = {
|
|
|
8846
9044
|
satellite: "satellite-",
|
|
8847
9045
|
dark: "dark-"
|
|
8848
9046
|
};
|
|
8849
|
-
const EXTERNAL_STYLE_URLS = {
|
|
8850
|
-
streets: "https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json",
|
|
8851
|
-
dark: "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"
|
|
8852
|
-
};
|
|
8853
9047
|
const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
8854
9048
|
className,
|
|
8855
9049
|
enableDrawing = true,
|
|
@@ -8869,8 +9063,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8869
9063
|
showDebugSidebar = false,
|
|
8870
9064
|
initialCenter = [-74.006, 40.7128],
|
|
8871
9065
|
initialZoom = 12,
|
|
8872
|
-
baseMapStyle = "streets",
|
|
8873
|
-
|
|
9066
|
+
baseMapStyle: requestedBaseMapStyle = "streets",
|
|
9067
|
+
endpoints,
|
|
9068
|
+
customBasemaps: customBasemapsProp,
|
|
8874
9069
|
basemapOrder,
|
|
8875
9070
|
initialDrawingMode,
|
|
8876
9071
|
onFeatureSelect,
|
|
@@ -8887,8 +9082,6 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8887
9082
|
onClearFilter,
|
|
8888
9083
|
showGoToButton = false,
|
|
8889
9084
|
onDropPoint,
|
|
8890
|
-
geocodingUrl,
|
|
8891
|
-
geocoderProvider,
|
|
8892
9085
|
onSearchEngineRequest,
|
|
8893
9086
|
onWorkspaceLoad,
|
|
8894
9087
|
onWorkspaceSave,
|
|
@@ -8903,12 +9096,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8903
9096
|
featureSaveProvider,
|
|
8904
9097
|
featureRefreshProvider,
|
|
8905
9098
|
tooltipProvider,
|
|
8906
|
-
glyphsUrl,
|
|
8907
9099
|
filterGeometry,
|
|
8908
|
-
enableSatellite = true,
|
|
8909
|
-
enableTerrain = true,
|
|
8910
|
-
enableDark = true,
|
|
8911
|
-
enable3D = true,
|
|
8912
9100
|
hideBasemapSwitcher = false,
|
|
8913
9101
|
externalPersistence = false,
|
|
8914
9102
|
enableKeyboardShortcuts = true,
|
|
@@ -8929,6 +9117,18 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8929
9117
|
onEntityContextMenu
|
|
8930
9118
|
}, ref) {
|
|
8931
9119
|
const mapContainer = useRef(null);
|
|
9120
|
+
const [resolvedEndpoints] = useState(() => resolveEndpoints(endpoints));
|
|
9121
|
+
const [baseMapStyle] = useState(() => {
|
|
9122
|
+
if (!resolvedEndpoints.vectorStyles.streets) {
|
|
9123
|
+
console.warn("[map-component] streets is turned off in endpoints.");
|
|
9124
|
+
}
|
|
9125
|
+
const id = initialBasemapId(resolvedEndpoints, requestedBaseMapStyle);
|
|
9126
|
+
if (id !== requestedBaseMapStyle) {
|
|
9127
|
+
console.warn(`[map-component] basemap "${requestedBaseMapStyle}" is turned off in endpoints; opening on "${id}".`);
|
|
9128
|
+
}
|
|
9129
|
+
return id;
|
|
9130
|
+
});
|
|
9131
|
+
const customBasemaps = useMemo(() => customBasemapsWithoutBuiltIns(customBasemapsProp), [customBasemapsProp]);
|
|
8932
9132
|
const map = useRef(null);
|
|
8933
9133
|
const draw = useRef(null);
|
|
8934
9134
|
const fileInputRef = useRef(null);
|
|
@@ -8945,19 +9145,19 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8945
9145
|
const readOnlyFeatures = useRef(/* @__PURE__ */ new Map());
|
|
8946
9146
|
const layerTemporalCacheRef = useRef(/* @__PURE__ */ new Map());
|
|
8947
9147
|
const timelineUpdateTimerRef = useRef(null);
|
|
8948
|
-
const loadedBasemaps = useRef(new Set(
|
|
8949
|
-
const basemapLayerIds = useRef(new Map(
|
|
9148
|
+
const loadedBasemaps = useRef(new Set(resolvedEndpoints.satellite ? ["satellite"] : []));
|
|
9149
|
+
const basemapLayerIds = useRef(new Map(resolvedEndpoints.satellite ? [["satellite", ["satellite-layer"]]] : []));
|
|
8950
9150
|
const availableBasemaps = useMemo(() => {
|
|
8951
9151
|
const iconFor = (id) => {
|
|
8952
9152
|
var _a;
|
|
8953
9153
|
return ((_a = MAP_STYLES.find((style) => style.id === id)) == null ? void 0 : _a.icon) ?? Map$1;
|
|
8954
9154
|
};
|
|
8955
|
-
return resolveBasemapChoices(basemapOrder, customBasemaps).map((choice) => ({
|
|
9155
|
+
return resolveBasemapChoices(basemapOrder, customBasemaps, resolvedEndpoints.builtInBasemaps).map((choice) => ({
|
|
8956
9156
|
id: choice.id,
|
|
8957
9157
|
name: choice.name,
|
|
8958
9158
|
icon: iconFor(choice.id)
|
|
8959
9159
|
}));
|
|
8960
|
-
}, [basemapOrder, customBasemaps]);
|
|
9160
|
+
}, [basemapOrder, customBasemaps, resolvedEndpoints]);
|
|
8961
9161
|
const loadingBasemaps = useRef(/* @__PURE__ */ new Set());
|
|
8962
9162
|
const customBasemapRegistry = useRef(/* @__PURE__ */ new Map());
|
|
8963
9163
|
const clusterPieManagers = useRef(/* @__PURE__ */ new Map());
|
|
@@ -9188,6 +9388,19 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9188
9388
|
}
|
|
9189
9389
|
return getReadOnlyFeatureById(id);
|
|
9190
9390
|
}, [getReadOnlyFeatureById]);
|
|
9391
|
+
const appliedSelectionRef = useRef(/* @__PURE__ */ new Map());
|
|
9392
|
+
const locatorCacheRef = useRef(createLocatorCache());
|
|
9393
|
+
const shardedLayerIdsRef = useRef(EMPTY_ID_SET);
|
|
9394
|
+
const overlayPaintContextRef = useRef(null);
|
|
9395
|
+
const shardFieldRangesRef = useRef(/* @__PURE__ */ new Map());
|
|
9396
|
+
const locateSelectionSources = useCallback((id) => {
|
|
9397
|
+
if (getFeatureById(id) === null) return EMPTY_SOURCES;
|
|
9398
|
+
return locateFeatureSources(
|
|
9399
|
+
id,
|
|
9400
|
+
{ readOnly: readOnlyFeatures.current, shardedLayerIds: shardedLayerIdsRef.current, shardSize: shardSizeRef.current },
|
|
9401
|
+
locatorCacheRef.current
|
|
9402
|
+
);
|
|
9403
|
+
}, [getFeatureById]);
|
|
9191
9404
|
const canDeleteSelected = useMemo(() => {
|
|
9192
9405
|
if (selectedFeatureIds.length === 0) return false;
|
|
9193
9406
|
return selectedFeatureIds.some((id) => {
|
|
@@ -9209,7 +9422,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9209
9422
|
return true;
|
|
9210
9423
|
});
|
|
9211
9424
|
}, [selectedFeatureIds, hiddenDrawingTools, getFeatureById]);
|
|
9212
|
-
const applySelectionState = useCallback((nextIds, options) => {
|
|
9425
|
+
const applySelectionState$1 = useCallback((nextIds, options) => {
|
|
9213
9426
|
if (!isMapLoaded || !draw.current) {
|
|
9214
9427
|
setSelectedFeatureIds(nextIds);
|
|
9215
9428
|
if (options == null ? void 0 : options.focusProperties) setShowProperties(nextIds.length > 0);
|
|
@@ -9280,6 +9493,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9280
9493
|
});
|
|
9281
9494
|
const trySelectionFastPathRef = useRef(null);
|
|
9282
9495
|
const tryTimelineFastPathRef = useRef(null);
|
|
9496
|
+
const reconcileSelectionRef = useRef(null);
|
|
9283
9497
|
const syncCoalescerRef = useRef(null);
|
|
9284
9498
|
if (syncCoalescerRef.current === null) {
|
|
9285
9499
|
syncCoalescerRef.current = createRafCoalescer((reasons) => {
|
|
@@ -9480,7 +9694,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9480
9694
|
}
|
|
9481
9695
|
}, []);
|
|
9482
9696
|
const syncFeaturesToCustomLayers = useCallback(() => {
|
|
9483
|
-
var _a, _b;
|
|
9697
|
+
var _a, _b, _c;
|
|
9484
9698
|
if (!map.current) return;
|
|
9485
9699
|
if (isSyncingRef.current) return;
|
|
9486
9700
|
isSyncingRef.current = true;
|
|
@@ -9489,11 +9703,6 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9489
9703
|
const source = map.current.getSource("custom-features");
|
|
9490
9704
|
if (!source) return;
|
|
9491
9705
|
const drawFeatures = draw.current ? draw.current.getAll() : { type: "FeatureCollection", features: [] };
|
|
9492
|
-
const drawSelectedIds = draw.current ? draw.current.getSelectedIds() : [];
|
|
9493
|
-
const componentSelectedIds = selectedFeatureIdsRef.current;
|
|
9494
|
-
const selectedIdSet = /* @__PURE__ */ new Set();
|
|
9495
|
-
drawSelectedIds.forEach((id) => selectedIdSet.add(String(id)));
|
|
9496
|
-
componentSelectedIds.forEach((id) => selectedIdSet.add(String(id)));
|
|
9497
9706
|
const visibleSet = timelineVisibleIdsRef.current;
|
|
9498
9707
|
const currentLayers = layersRef.current;
|
|
9499
9708
|
const isLayerVisible = (layer) => {
|
|
@@ -9505,6 +9714,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9505
9714
|
const count = ((_a2 = readOnlyFeatures.current.get(layer.id)) == null ? void 0 : _a2.length) ?? 0;
|
|
9506
9715
|
if (isShardEligible(layer, count, shardSizeRef.current)) shardedLayerIds.add(layer.id);
|
|
9507
9716
|
});
|
|
9717
|
+
shardedLayerIdsRef.current = shardedLayerIds;
|
|
9508
9718
|
const allFeatures = [...drawFeatures.features];
|
|
9509
9719
|
readOnlyFeatures.current.forEach((features, layerId) => {
|
|
9510
9720
|
if (shardedLayerIds.has(layerId)) return;
|
|
@@ -9589,8 +9799,6 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9589
9799
|
const paintCache = createSelectionPaintCache();
|
|
9590
9800
|
const paintContext = {
|
|
9591
9801
|
timelineVisibleIds: visibleSet,
|
|
9592
|
-
selectedIds: selectedIdSet,
|
|
9593
|
-
selectionEnabled: enableSelectionRef.current || enableDrawingRef.current,
|
|
9594
9802
|
sizeFieldRanges,
|
|
9595
9803
|
colorFieldRanges,
|
|
9596
9804
|
tracePointIds,
|
|
@@ -9604,21 +9812,15 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9604
9812
|
features: allFeatures.map((f, i) => {
|
|
9605
9813
|
const styled = styleFeatureForPaint(f, featureToLayer.get(String(f.id)), paintContext, i >= drawFeatureCount);
|
|
9606
9814
|
const p = styled.paint;
|
|
9607
|
-
recordPaintedFeature(
|
|
9608
|
-
paintCache,
|
|
9609
|
-
p.featureId,
|
|
9610
|
-
p.basePriority,
|
|
9611
|
-
p.selected,
|
|
9612
|
-
p.visibleStrokeOpacity,
|
|
9613
|
-
p.visibleFillOpacity,
|
|
9614
|
-
p.timelineHidden
|
|
9615
|
-
);
|
|
9815
|
+
recordPaintedFeature(paintCache, p.featureId, p.visibleStrokeOpacity, p.visibleFillOpacity, p.timelineHidden);
|
|
9616
9816
|
if (styled.tracePaint) tracePointPaint.set(p.featureId, styled.tracePaint);
|
|
9617
9817
|
return styled.feature;
|
|
9618
9818
|
})
|
|
9619
9819
|
};
|
|
9620
9820
|
source.setData(sourceData);
|
|
9621
9821
|
selectionPaintCacheRef.current = paintCache;
|
|
9822
|
+
overlayPaintContextRef.current = paintContext;
|
|
9823
|
+
(_a = reconcileSelectionRef.current) == null ? void 0 : _a.call(reconcileSelectionRef);
|
|
9622
9824
|
const traceSource = map.current.getSource("trace-features");
|
|
9623
9825
|
if (traceSource) traceSource.setData({ type: "FeatureCollection", features: traceSegments });
|
|
9624
9826
|
tracePaintCacheRef.current = traceSource && paintedTraceGroups.length > 0 ? { groups: paintedTraceGroups, pointPaint: tracePointPaint } : null;
|
|
@@ -9632,7 +9834,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9632
9834
|
sawArrowFeature = true;
|
|
9633
9835
|
if (f.geometry.type === "LineString") arrowLines.push(f);
|
|
9634
9836
|
});
|
|
9635
|
-
const shardArrows = ((
|
|
9837
|
+
const shardArrows = ((_b = shardRegistryRef.current) == null ? void 0 : _b.arrowLines((id) => {
|
|
9636
9838
|
var _a2;
|
|
9637
9839
|
return ((_a2 = currentLayers.find((l) => l.id === id)) == null ? void 0 : _a2.visible) === true;
|
|
9638
9840
|
})) ?? [];
|
|
@@ -9652,7 +9854,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9652
9854
|
setVisibleFeatureCount(countVisibleFeatures(threshold));
|
|
9653
9855
|
setLabelsSuppressed(false);
|
|
9654
9856
|
}
|
|
9655
|
-
(
|
|
9857
|
+
(_c = applyShardedLayersRef.current) == null ? void 0 : _c.call(applyShardedLayersRef);
|
|
9656
9858
|
const requestedBy = fullSyncCallersRef.current.splice(0);
|
|
9657
9859
|
let shardedFeatures = 0;
|
|
9658
9860
|
shardedLayerIds.forEach((id) => {
|
|
@@ -9749,21 +9951,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9749
9951
|
if (!m || !registry) return;
|
|
9750
9952
|
const currentLayers = layersRef.current;
|
|
9751
9953
|
const shardSize2 = shardSizeRef.current;
|
|
9752
|
-
const selectionEnabled = enableSelectionRef.current || enableDrawingRef.current;
|
|
9753
|
-
const currentSelectedIds = () => {
|
|
9754
|
-
var _a;
|
|
9755
|
-
const ids = /* @__PURE__ */ new Set();
|
|
9756
|
-
if (selectionEnabled) {
|
|
9757
|
-
(((_a = draw.current) == null ? void 0 : _a.getSelectedIds()) ?? []).forEach((id) => ids.add(String(id)));
|
|
9758
|
-
selectedFeatureIdsRef.current.forEach((id) => ids.add(String(id)));
|
|
9759
|
-
}
|
|
9760
|
-
return ids;
|
|
9761
|
-
};
|
|
9762
9954
|
currentLayers.forEach((layer) => {
|
|
9763
9955
|
var _a;
|
|
9764
9956
|
const features = readOnlyFeatures.current.get(layer.id) ?? [];
|
|
9765
9957
|
if (!isShardEligible(layer, features.length, shardSize2)) {
|
|
9766
9958
|
registry.remove(layer.id);
|
|
9959
|
+
shardFieldRangesRef.current.delete(layer.id);
|
|
9767
9960
|
setLayerImporting(layer.id, false);
|
|
9768
9961
|
return;
|
|
9769
9962
|
}
|
|
@@ -9773,10 +9966,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9773
9966
|
setLayerImporting(layer.id, false);
|
|
9774
9967
|
return;
|
|
9775
9968
|
}
|
|
9776
|
-
const fingerprint = buildShardFingerprint(layer, features,
|
|
9969
|
+
const fingerprint = buildShardFingerprint(layer, features, shardSize2);
|
|
9777
9970
|
const expectedShards = shardRanges(features.length, shardSize2).length;
|
|
9778
9971
|
if (shardFingerprintsEqual(state.fingerprint, fingerprint) && state.stacks.length === expectedShards) {
|
|
9779
|
-
if (reconcileShardCaches(registry, state.layerId, expectedShards,
|
|
9972
|
+
if (reconcileShardCaches(registry, state.layerId, expectedShards, timelineVisibleIdsRef.current)) {
|
|
9780
9973
|
setLayerImporting(layer.id, false);
|
|
9781
9974
|
mapPerfLog("shards", "pass skipped (fingerprint)", { layerId: layer.id, shards: expectedShards });
|
|
9782
9975
|
return;
|
|
@@ -9796,10 +9989,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9796
9989
|
const ranges = layerFieldRanges(layer.visualConfig, (visit) => {
|
|
9797
9990
|
for (let i = 0; i < features.length; i++) visit(features[i].properties);
|
|
9798
9991
|
});
|
|
9992
|
+
shardFieldRangesRef.current.set(layer.id, ranges);
|
|
9799
9993
|
const sizeFieldRanges = /* @__PURE__ */ new Map();
|
|
9800
9994
|
const colorFieldRanges = /* @__PURE__ */ new Map();
|
|
9801
9995
|
if (ranges.size) sizeFieldRanges.set(layer.id, ranges.size);
|
|
9802
9996
|
if (ranges.color) colorFieldRanges.set(layer.id, ranges.color);
|
|
9997
|
+
let overlayRestyled = false;
|
|
9803
9998
|
void runShardPass({
|
|
9804
9999
|
layer,
|
|
9805
10000
|
features,
|
|
@@ -9810,8 +10005,6 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9810
10005
|
contextForShard: () => {
|
|
9811
10006
|
return {
|
|
9812
10007
|
timelineVisibleIds: timelineVisibleIdsRef.current,
|
|
9813
|
-
selectedIds: currentSelectedIds(),
|
|
9814
|
-
selectionEnabled,
|
|
9815
10008
|
sizeFieldRanges,
|
|
9816
10009
|
colorFieldRanges,
|
|
9817
10010
|
// Trace-enabled layers are never sharded, so these are empty by construction.
|
|
@@ -9822,7 +10015,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9822
10015
|
};
|
|
9823
10016
|
},
|
|
9824
10017
|
onShardPainted: (index, cache2) => {
|
|
10018
|
+
var _a2;
|
|
9825
10019
|
state.caches[index] = cache2;
|
|
10020
|
+
(_a2 = reconcileSelectionRef.current) == null ? void 0 : _a2.call(reconcileSelectionRef, { overlay: !overlayRestyled });
|
|
10021
|
+
overlayRestyled = true;
|
|
9826
10022
|
},
|
|
9827
10023
|
onProgress: (painted) => progress == null ? void 0 : progress.update(painted)
|
|
9828
10024
|
}).then((result) => {
|
|
@@ -10013,7 +10209,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10013
10209
|
});
|
|
10014
10210
|
const registry = shardRegistryRef.current;
|
|
10015
10211
|
registry == null ? void 0 : registry.trackedLayerIds().forEach((layerId) => {
|
|
10016
|
-
if (!liveLayerIds.has(layerId))
|
|
10212
|
+
if (!liveLayerIds.has(layerId)) {
|
|
10213
|
+
registry.remove(layerId);
|
|
10214
|
+
shardFieldRangesRef.current.delete(layerId);
|
|
10215
|
+
}
|
|
10017
10216
|
});
|
|
10018
10217
|
Object.keys((style == null ? void 0 : style.sources) ?? {}).forEach((sid) => {
|
|
10019
10218
|
const parsed = parseShardSourceId(sid);
|
|
@@ -10136,15 +10335,15 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10136
10335
|
coalesceKey,
|
|
10137
10336
|
undo: () => {
|
|
10138
10337
|
applyHistoryState(featureIds, layerIds, beforeF, beforeL);
|
|
10139
|
-
applySelectionState(beforeSelectedIds, { focusProperties: false });
|
|
10338
|
+
applySelectionState$1(beforeSelectedIds, { focusProperties: false });
|
|
10140
10339
|
},
|
|
10141
10340
|
redo: () => {
|
|
10142
10341
|
applyHistoryState(featureIds, layerIds, afterF, afterL);
|
|
10143
|
-
applySelectionState(afterSelectedIds, { focusProperties: false });
|
|
10342
|
+
applySelectionState$1(afterSelectedIds, { focusProperties: false });
|
|
10144
10343
|
}
|
|
10145
10344
|
};
|
|
10146
10345
|
},
|
|
10147
|
-
[applyHistoryState, applySelectionState]
|
|
10346
|
+
[applyHistoryState, applySelectionState$1]
|
|
10148
10347
|
);
|
|
10149
10348
|
const finalizeCapture = useCallback(() => {
|
|
10150
10349
|
const pending = pendingCaptureRef.current;
|
|
@@ -10200,11 +10399,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10200
10399
|
if (!mapContainer.current || map.current) return;
|
|
10201
10400
|
let removeDrawGateListeners;
|
|
10202
10401
|
try {
|
|
10203
|
-
const baseStyle = createBaseStyle(
|
|
10204
|
-
glyphsUrl,
|
|
10205
|
-
enableSatellite,
|
|
10206
|
-
enableTerrain
|
|
10207
|
-
});
|
|
10402
|
+
const baseStyle = createBaseStyle(resolvedEndpoints);
|
|
10208
10403
|
const mapInstance = new maplibregl.Map({
|
|
10209
10404
|
container: mapContainer.current,
|
|
10210
10405
|
style: baseStyle,
|
|
@@ -10272,11 +10467,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10272
10467
|
var _a, _b;
|
|
10273
10468
|
map.current = mapInstance;
|
|
10274
10469
|
draw.current = drawInstance;
|
|
10275
|
-
mapInstance.addSource(
|
|
10276
|
-
type: "geojson",
|
|
10277
|
-
data: { type: "FeatureCollection", features: [] },
|
|
10278
|
-
maxzoom: 22
|
|
10279
|
-
});
|
|
10470
|
+
mapInstance.addSource(SHARED_SOURCE_ID, customSourceSpec());
|
|
10280
10471
|
const sharedStack = buildCustomLayerStack(SHARED_SOURCE_ID, CUSTOM_LAYER_ROLES, { labelsVisible: false });
|
|
10281
10472
|
sharedStack.forEach((spec) => mapInstance.addLayer(spec));
|
|
10282
10473
|
const styleHost = {
|
|
@@ -10367,6 +10558,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10367
10558
|
"line-opacity": 0.7
|
|
10368
10559
|
}
|
|
10369
10560
|
});
|
|
10561
|
+
mapInstance.addSource(SELECTION_OVERLAY_SOURCE_ID, {
|
|
10562
|
+
type: "geojson",
|
|
10563
|
+
data: { type: "FeatureCollection", features: [] },
|
|
10564
|
+
maxzoom: 22
|
|
10565
|
+
});
|
|
10566
|
+
buildSelectionOverlayStack().forEach((spec) => mapInstance.addLayer(spec));
|
|
10370
10567
|
if (tooltipElRef.current) {
|
|
10371
10568
|
const prevCleanup = tooltipElRef.current._cleanup;
|
|
10372
10569
|
try {
|
|
@@ -10485,8 +10682,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10485
10682
|
const highlightFields = /* @__PURE__ */ new Set();
|
|
10486
10683
|
if (((_a2 = visualConfig == null ? void 0 : visualConfig.size) == null ? void 0 : _a2.mode) === "field" && visualConfig.size.fieldName) highlightFields.add(visualConfig.size.fieldName);
|
|
10487
10684
|
if (((_b2 = visualConfig == null ? void 0 : visualConfig.color) == null ? void 0 : _b2.mode) === "field" && visualConfig.color.fieldName) highlightFields.add(visualConfig.color.fieldName);
|
|
10488
|
-
const
|
|
10489
|
-
const displayProps = Object.entries(props).filter(([key, value]) => !excludeKeys.includes(key) && !key.startsWith("_") && !key.startsWith("isHidden") && !key.startsWith("isTrace") && !key.startsWith("isTimeline") && !key.startsWith("trace") && value != null && value !== "").slice(0, 5);
|
|
10685
|
+
const displayProps = Object.entries(props).filter(([key, value]) => !TOOLTIP_EXCLUDED_KEYS.includes(key) && !key.startsWith("_") && !key.startsWith("isHidden") && !key.startsWith("isTrace") && !key.startsWith("isTimeline") && !key.startsWith("trace") && value != null && value !== "").slice(0, 5);
|
|
10490
10686
|
const name = props.name;
|
|
10491
10687
|
let html = '<div class="text-sm space-y-0.5">';
|
|
10492
10688
|
if (name) html += `<div class="font-medium">${name}</div>`;
|
|
@@ -10777,7 +10973,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10777
10973
|
onMapLoad == null ? void 0 : onMapLoad(mapInstance);
|
|
10778
10974
|
if (baseMapStyle !== "satellite") {
|
|
10779
10975
|
const customDef = customBasemaps == null ? void 0 : customBasemaps[baseMapStyle];
|
|
10780
|
-
const styleUrl = (customDef == null ? void 0 : customDef.type) === "vector" && typeof customDef.style === "string" ? customDef.style :
|
|
10976
|
+
const styleUrl = (customDef == null ? void 0 : customDef.type) === "vector" && typeof customDef.style === "string" ? customDef.style : builtInStyleUrl(resolvedEndpoints, baseMapStyle);
|
|
10781
10977
|
if (styleUrl) {
|
|
10782
10978
|
const prefix = BASEMAP_LAYER_PREFIXES[baseMapStyle] || `${baseMapStyle}-`;
|
|
10783
10979
|
fetch(styleUrl).then((res) => res.json()).then((externalStyle) => {
|
|
@@ -10791,8 +10987,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10791
10987
|
return url;
|
|
10792
10988
|
}
|
|
10793
10989
|
};
|
|
10794
|
-
|
|
10795
|
-
if (externalStyle.glyphs && !usingLocalGlyphs) {
|
|
10990
|
+
if (externalStyle.glyphs && resolvedEndpoints.adoptStyleGlyphs) {
|
|
10796
10991
|
mapInstance.setGlyphs(resolveUrl(externalStyle.glyphs));
|
|
10797
10992
|
}
|
|
10798
10993
|
if (externalStyle.sprite) {
|
|
@@ -11163,7 +11358,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11163
11358
|
const clusterHit = clusterOverlayIds.length > 0 ? mapInstance.queryRenderedFeatures(e.point, { layers: clusterOverlayIds })[0] : void 0;
|
|
11164
11359
|
if (!clusterHit) {
|
|
11165
11360
|
if (selectedFeatureIdsRef.current.length > 0 && !isModifierKey) {
|
|
11166
|
-
applySelectionState([]);
|
|
11361
|
+
applySelectionState$1([]);
|
|
11167
11362
|
}
|
|
11168
11363
|
return;
|
|
11169
11364
|
}
|
|
@@ -11185,13 +11380,13 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11185
11380
|
return;
|
|
11186
11381
|
}
|
|
11187
11382
|
const fid = String(featureId);
|
|
11188
|
-
const
|
|
11189
|
-
const isAlreadySelected =
|
|
11383
|
+
const currentSelection2 = selectedFeatureIdsRef.current;
|
|
11384
|
+
const isAlreadySelected = currentSelection2.includes(fid);
|
|
11190
11385
|
let nextIds;
|
|
11191
11386
|
if (isModifierKey) {
|
|
11192
|
-
nextIds = isAlreadySelected ?
|
|
11387
|
+
nextIds = isAlreadySelected ? currentSelection2.filter((id) => id !== fid) : [...currentSelection2, fid];
|
|
11193
11388
|
} else {
|
|
11194
|
-
nextIds = isAlreadySelected ?
|
|
11389
|
+
nextIds = isAlreadySelected ? currentSelection2.filter((id) => id !== fid) : [fid];
|
|
11195
11390
|
}
|
|
11196
11391
|
isSelectingReadOnlyRef.current = true;
|
|
11197
11392
|
if (drawInstance.getSelected().features.length > 0) {
|
|
@@ -11743,7 +11938,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11743
11938
|
onFeatureDelete == null ? void 0 : onFeatureDelete(featureIds);
|
|
11744
11939
|
},
|
|
11745
11940
|
selectFeatures: (featureIds) => {
|
|
11746
|
-
applySelectionState(featureIds, { focusProperties: true });
|
|
11941
|
+
applySelectionState$1(featureIds, { focusProperties: true });
|
|
11747
11942
|
},
|
|
11748
11943
|
getSelectedFeatures,
|
|
11749
11944
|
setEditMode: (enabled) => {
|
|
@@ -11849,6 +12044,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11849
12044
|
// Basemap management methods
|
|
11850
12045
|
registerBasemap: (id, definition) => {
|
|
11851
12046
|
if (!map.current) return;
|
|
12047
|
+
if (BUILT_IN_BASEMAP_IDS.includes(id)) {
|
|
12048
|
+
console.warn(`[map-component] registerBasemap("${id}") ignored: built-in basemaps are configured through the endpoints prop.`);
|
|
12049
|
+
return;
|
|
12050
|
+
}
|
|
11852
12051
|
customBasemapRegistry.current.set(id, definition);
|
|
11853
12052
|
if (definition.type === "raster") {
|
|
11854
12053
|
const sourceId = `custom-basemap-${id}`;
|
|
@@ -11875,8 +12074,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11875
12074
|
},
|
|
11876
12075
|
unregisterBasemap: (id) => {
|
|
11877
12076
|
if (!map.current) return false;
|
|
11878
|
-
|
|
11879
|
-
if (builtIn.includes(id)) return false;
|
|
12077
|
+
if (BUILT_IN_BASEMAP_IDS.includes(id)) return false;
|
|
11880
12078
|
customBasemapRegistry.current.delete(id);
|
|
11881
12079
|
const layerIds = basemapLayerIds.current.get(id) || [];
|
|
11882
12080
|
for (const layerId of layerIds) {
|
|
@@ -11900,7 +12098,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11900
12098
|
return currentMapStyle;
|
|
11901
12099
|
},
|
|
11902
12100
|
listBasemaps: () => {
|
|
11903
|
-
const builtIn =
|
|
12101
|
+
const builtIn = resolvedEndpoints.builtInBasemaps.map((basemap) => basemap.id);
|
|
11904
12102
|
const custom = Array.from(customBasemapRegistry.current.keys());
|
|
11905
12103
|
return [...builtIn, ...custom];
|
|
11906
12104
|
},
|
|
@@ -12029,7 +12227,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12029
12227
|
setPersistedSelectionPolygon(null);
|
|
12030
12228
|
setSelectionPoints([]);
|
|
12031
12229
|
setSelectedFeatureIds([]);
|
|
12032
|
-
applySelectionState([], { focusProperties: true });
|
|
12230
|
+
applySelectionState$1([], { focusProperties: true });
|
|
12033
12231
|
},
|
|
12034
12232
|
// Viewport and state getters
|
|
12035
12233
|
getViewport: () => {
|
|
@@ -13017,6 +13215,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13017
13215
|
if (!m.getLayer(id)) return;
|
|
13018
13216
|
m.moveLayer(id, firstVisibleBasemapSymbol == null ? void 0 : firstVisibleBasemapSymbol.id);
|
|
13019
13217
|
});
|
|
13218
|
+
if (!firstVisibleBasemapSymbol && m.getLayer(SELECTION_OVERLAY_LAYER_IDS.label)) {
|
|
13219
|
+
m.moveLayer(SELECTION_OVERLAY_LAYER_IDS.label);
|
|
13220
|
+
}
|
|
13020
13221
|
} catch (e) {
|
|
13021
13222
|
console.warn("[map-component] moveLabelsBeforeBasemapSymbols failed:", (e == null ? void 0 : e.message) ?? e);
|
|
13022
13223
|
}
|
|
@@ -13026,7 +13227,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13026
13227
|
if (!map.current) return [];
|
|
13027
13228
|
const mapInstance = map.current;
|
|
13028
13229
|
const prefix = BASEMAP_LAYER_PREFIXES[styleName] || `${styleName}-`;
|
|
13029
|
-
const styleUrl = overrideStyleUrl ||
|
|
13230
|
+
const styleUrl = overrideStyleUrl || builtInStyleUrl(resolvedEndpoints, styleName);
|
|
13030
13231
|
if (!styleUrl) {
|
|
13031
13232
|
console.warn(`No external style URL for: ${styleName}`);
|
|
13032
13233
|
return [];
|
|
@@ -13043,8 +13244,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13043
13244
|
return url;
|
|
13044
13245
|
}
|
|
13045
13246
|
};
|
|
13046
|
-
|
|
13047
|
-
if (externalStyle.glyphs && !usingLocalGlyphs) {
|
|
13247
|
+
if (externalStyle.glyphs && resolvedEndpoints.adoptStyleGlyphs) {
|
|
13048
13248
|
mapInstance.setGlyphs(resolveUrl(externalStyle.glyphs));
|
|
13049
13249
|
}
|
|
13050
13250
|
if (externalStyle.sprite) {
|
|
@@ -13091,7 +13291,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13091
13291
|
console.error(`Failed to load basemap style ${styleName}:`, e);
|
|
13092
13292
|
return [];
|
|
13093
13293
|
}
|
|
13094
|
-
}, [moveLabelsBeforeBasemapSymbols]);
|
|
13294
|
+
}, [moveLabelsBeforeBasemapSymbols, resolvedEndpoints]);
|
|
13095
13295
|
const setBasemapVisibility = useCallback((styleName, visible) => {
|
|
13096
13296
|
if (!map.current) return;
|
|
13097
13297
|
const mapInstance = map.current;
|
|
@@ -13105,6 +13305,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13105
13305
|
const handleMapStyleChange = useCallback(async (style) => {
|
|
13106
13306
|
if (!map.current) return;
|
|
13107
13307
|
const mapInstance = map.current;
|
|
13308
|
+
if (BUILT_IN_BASEMAP_IDS.includes(style) && !isBuiltInBasemapEnabled(resolvedEndpoints, style)) {
|
|
13309
|
+
console.warn(`[map-component] basemap "${style}" is turned off in endpoints; ignoring the switch.`);
|
|
13310
|
+
return;
|
|
13311
|
+
}
|
|
13108
13312
|
basemapLayerIds.current.forEach((_, basemapName) => {
|
|
13109
13313
|
setBasemapVisibility(basemapName, false);
|
|
13110
13314
|
});
|
|
@@ -13150,7 +13354,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13150
13354
|
setBasemapVisibility(style, true);
|
|
13151
13355
|
setCurrentMapStyle(style);
|
|
13152
13356
|
moveLabelsBeforeBasemapSymbols();
|
|
13153
|
-
}, [loadBasemapStyle, setBasemapVisibility, moveLabelsBeforeBasemapSymbols]);
|
|
13357
|
+
}, [loadBasemapStyle, setBasemapVisibility, moveLabelsBeforeBasemapSymbols, resolvedEndpoints]);
|
|
13154
13358
|
handleMapStyleChangeRef.current = handleMapStyleChange;
|
|
13155
13359
|
const handleUpdateTraceConfig = useCallback((layerId, config) => {
|
|
13156
13360
|
saveStateForUndo("trace config", { coalesceKey: `traceConfig:${layerId}` });
|
|
@@ -13500,7 +13704,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13500
13704
|
}, [isEditMode]);
|
|
13501
13705
|
const handleToggle3DTerrain = useCallback(() => {
|
|
13502
13706
|
if (!map.current) return;
|
|
13503
|
-
if (!
|
|
13707
|
+
if (!resolvedEndpoints.terrain) {
|
|
13504
13708
|
toast({
|
|
13505
13709
|
title: "3D Terrain Unavailable",
|
|
13506
13710
|
description: "Terrain features are disabled for this configuration.",
|
|
@@ -13545,7 +13749,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13545
13749
|
mapInstance.setLayoutProperty("terrain-hillshade", "visibility", "none");
|
|
13546
13750
|
}
|
|
13547
13751
|
}
|
|
13548
|
-
}, [is3DTerrainEnabled,
|
|
13752
|
+
}, [is3DTerrainEnabled, resolvedEndpoints, toast]);
|
|
13549
13753
|
const handleSelectionModeChange = useCallback((mode) => {
|
|
13550
13754
|
setSelectionMode(mode);
|
|
13551
13755
|
setSelectionPoints([]);
|
|
@@ -13568,24 +13772,91 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13568
13772
|
useEffect(() => {
|
|
13569
13773
|
enableDrawingRef.current = enableDrawing;
|
|
13570
13774
|
}, [enableDrawing]);
|
|
13571
|
-
const
|
|
13775
|
+
const overlayPaintContext = useCallback(() => {
|
|
13776
|
+
const base = overlayPaintContextRef.current;
|
|
13777
|
+
if (!base) return null;
|
|
13778
|
+
const sizeFieldRanges = new Map(base.sizeFieldRanges);
|
|
13779
|
+
const colorFieldRanges = new Map(base.colorFieldRanges);
|
|
13780
|
+
shardFieldRangesRef.current.forEach((ranges, layerId) => {
|
|
13781
|
+
if (ranges.size) sizeFieldRanges.set(layerId, ranges.size);
|
|
13782
|
+
if (ranges.color) colorFieldRanges.set(layerId, ranges.color);
|
|
13783
|
+
});
|
|
13784
|
+
return { ...base, timelineVisibleIds: timelineVisibleIdsRef.current, sizeFieldRanges, colorFieldRanges };
|
|
13785
|
+
}, []);
|
|
13786
|
+
const overlayFeatureCountRef = useRef(0);
|
|
13787
|
+
const overlayTimelineInputsRef = useRef(overlayTimelineInputs(EMPTY_ID_SET, null));
|
|
13788
|
+
const refreshSelectionOverlay = useCallback((m, ids) => {
|
|
13789
|
+
overlayTimelineInputsRef.current = overlayTimelineInputs(ids, timelineVisibleIdsRef.current);
|
|
13790
|
+
if (ids.size === 0 && overlayFeatureCountRef.current === 0) return;
|
|
13791
|
+
const overlay = m.getSource(SELECTION_OVERLAY_SOURCE_ID);
|
|
13792
|
+
if (!overlay) return;
|
|
13793
|
+
const ctx = ids.size > 0 ? overlayPaintContext() : null;
|
|
13794
|
+
const layers2 = layersRef.current;
|
|
13795
|
+
const layerById = new Map(layers2.map((l) => [l.id, l]));
|
|
13796
|
+
const data = buildSelectionOverlayData(ids, (id) => {
|
|
13797
|
+
if (!ctx) return [];
|
|
13798
|
+
const holders = locateFeatureHolders(id, readOnlyFeatures.current, locatorCacheRef.current);
|
|
13799
|
+
if (holders.length > 0) {
|
|
13800
|
+
return holders.filter((h) => {
|
|
13801
|
+
var _a;
|
|
13802
|
+
return ((_a = layerById.get(h.layerId)) == null ? void 0 : _a.visible) === true;
|
|
13803
|
+
}).map((h) => styleFeatureForPaint(h.feature, layerById.get(h.layerId), ctx, true).feature);
|
|
13804
|
+
}
|
|
13805
|
+
const feature = getFeatureById(id);
|
|
13806
|
+
if (!feature) return [];
|
|
13807
|
+
const layer = layers2.find((l) => !l.readOnly && l.featureIds.includes(id));
|
|
13808
|
+
return layer && !layer.visible ? [] : [styleFeatureForPaint(feature, layer, ctx, true).feature];
|
|
13809
|
+
});
|
|
13810
|
+
overlay.setData(data);
|
|
13811
|
+
overlayFeatureCountRef.current = data.features.length;
|
|
13812
|
+
}, [getFeatureById, overlayPaintContext]);
|
|
13813
|
+
const currentSelection = useCallback(() => {
|
|
13572
13814
|
var _a;
|
|
13815
|
+
if (!(enableSelectionRef.current || enableDrawingRef.current)) return null;
|
|
13816
|
+
const next = /* @__PURE__ */ new Set();
|
|
13817
|
+
(((_a = draw.current) == null ? void 0 : _a.getSelectedIds()) ?? []).forEach((id) => next.add(String(id)));
|
|
13818
|
+
selectedFeatureIdsRef.current.forEach((id) => next.add(String(id)));
|
|
13819
|
+
return next;
|
|
13820
|
+
}, []);
|
|
13821
|
+
const paintSelection = useCallback((m, overlay = true) => {
|
|
13822
|
+
const selection = currentSelection();
|
|
13823
|
+
const { set: set2, removed } = applySelectionState(
|
|
13824
|
+
appliedSelectionRef.current,
|
|
13825
|
+
selection ?? EMPTY_ID_SET,
|
|
13826
|
+
selection !== null,
|
|
13827
|
+
locateSelectionSources,
|
|
13828
|
+
featureStateHostFor(m)
|
|
13829
|
+
);
|
|
13830
|
+
const shown = selection ?? EMPTY_ID_SET;
|
|
13831
|
+
if (overlay) refreshSelectionOverlay(m, shown);
|
|
13832
|
+
return { set: set2, removed, overlay: overlay ? shown.size : 0 };
|
|
13833
|
+
}, [currentSelection, locateSelectionSources, refreshSelectionOverlay]);
|
|
13834
|
+
const applySelectionPaint = useCallback(() => {
|
|
13573
13835
|
const m = map.current;
|
|
13574
13836
|
if (!m) return true;
|
|
13575
|
-
const
|
|
13576
|
-
const
|
|
13577
|
-
|
|
13578
|
-
|
|
13579
|
-
|
|
13580
|
-
|
|
13581
|
-
|
|
13582
|
-
|
|
13583
|
-
|
|
13584
|
-
|
|
13585
|
-
|
|
13837
|
+
const start = performance.now();
|
|
13838
|
+
const painted = paintSelection(m);
|
|
13839
|
+
mapPerfLog("selection", "feature state applied", { ...painted, ms: Math.round(performance.now() - start) });
|
|
13840
|
+
return true;
|
|
13841
|
+
}, [paintSelection]);
|
|
13842
|
+
trySelectionFastPathRef.current = applySelectionPaint;
|
|
13843
|
+
const reconcileSelectionAfterPaint = useCallback((options) => {
|
|
13844
|
+
const m = map.current;
|
|
13845
|
+
if (!m) return;
|
|
13846
|
+
const { moved, pruned } = reconcileSelectionSources(
|
|
13847
|
+
appliedSelectionRef.current,
|
|
13848
|
+
locateSelectionSources,
|
|
13849
|
+
featureStateHostFor(m)
|
|
13586
13850
|
);
|
|
13587
|
-
|
|
13588
|
-
|
|
13851
|
+
const applied = paintSelection(m, (options == null ? void 0 : options.overlay) ?? true);
|
|
13852
|
+
if (moved || pruned || applied.set || applied.removed) {
|
|
13853
|
+
mapPerfLog("selection", "reconciled after paint", { moved, pruned, ...applied });
|
|
13854
|
+
}
|
|
13855
|
+
}, [locateSelectionSources, paintSelection]);
|
|
13856
|
+
reconcileSelectionRef.current = reconcileSelectionAfterPaint;
|
|
13857
|
+
useEffect(() => {
|
|
13858
|
+
scheduleSync("selection");
|
|
13859
|
+
}, [enableSelection, enableDrawing, scheduleSync]);
|
|
13589
13860
|
const tryTimelineFastPath = useCallback(() => {
|
|
13590
13861
|
const m = map.current;
|
|
13591
13862
|
if (!m) return true;
|
|
@@ -13599,13 +13870,17 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13599
13870
|
const traceDiff = trace && paintCache ? buildTraceTimelineDiff(trace, paintCache, nextVisible) : null;
|
|
13600
13871
|
const { applied, toggled } = applyTimelineFastPath(paintCache, nextVisible, source);
|
|
13601
13872
|
if (!applied || !paintCache || !source) return false;
|
|
13602
|
-
if (traceDiff && (!traceSource || !applyTraceTimelineDiff(traceDiff,
|
|
13873
|
+
if (traceDiff && (!traceSource || !applyTraceTimelineDiff(traceDiff, source, traceSource))) return false;
|
|
13603
13874
|
if (!forEachShardCache(shardRegistryRef.current, (cache2, shardSource) => applyTimelineFastPath(cache2, nextVisible, shardSource).applied)) {
|
|
13604
13875
|
return false;
|
|
13605
13876
|
}
|
|
13606
13877
|
const threshold = autoLabelConfig.enabled ? autoLabelConfig.threshold : 220;
|
|
13607
13878
|
setVisibleFeatureCount(countVisibleFeatures(threshold));
|
|
13608
13879
|
setLabelsSuppressed(false);
|
|
13880
|
+
const selection = currentSelection() ?? EMPTY_ID_SET;
|
|
13881
|
+
if (!sameOverlayTimelineInputs(overlayTimelineInputsRef.current, overlayTimelineInputs(selection, nextVisible))) {
|
|
13882
|
+
refreshSelectionOverlay(m, selection);
|
|
13883
|
+
}
|
|
13609
13884
|
mapPerfLog("timeline", "fast path applied", {
|
|
13610
13885
|
toggled,
|
|
13611
13886
|
endpointsMoved: (traceDiff == null ? void 0 : traceDiff.pointUpdates.length) ?? 0,
|
|
@@ -13613,7 +13888,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13613
13888
|
segmentsRemoved: (traceDiff == null ? void 0 : traceDiff.segmentRemove.length) ?? 0
|
|
13614
13889
|
});
|
|
13615
13890
|
return true;
|
|
13616
|
-
}, [autoLabelConfig, countVisibleFeatures]);
|
|
13891
|
+
}, [autoLabelConfig, countVisibleFeatures, currentSelection, refreshSelectionOverlay]);
|
|
13617
13892
|
tryTimelineFastPathRef.current = tryTimelineFastPath;
|
|
13618
13893
|
const collectSelectionFeatureGroups = useCallback(() => {
|
|
13619
13894
|
return collectVisibleFeatureGroups(
|
|
@@ -13729,7 +14004,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13729
14004
|
axisAlignedRectangle: true
|
|
13730
14005
|
});
|
|
13731
14006
|
const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
|
|
13732
|
-
applySelectionState(finalIds, { focusProperties: true });
|
|
14007
|
+
applySelectionState$1(finalIds, { focusProperties: true });
|
|
13733
14008
|
}
|
|
13734
14009
|
setIsSelectionToolActive(false);
|
|
13735
14010
|
startPoint = null;
|
|
@@ -13752,7 +14027,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13752
14027
|
} else {
|
|
13753
14028
|
const selectedIds = hitTestSelection(collectSelectionFeatureGroups(), selectionPolygon);
|
|
13754
14029
|
const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
|
|
13755
|
-
applySelectionState(finalIds, { focusProperties: true });
|
|
14030
|
+
applySelectionState$1(finalIds, { focusProperties: true });
|
|
13756
14031
|
}
|
|
13757
14032
|
setIsSelectionToolActive(false);
|
|
13758
14033
|
}
|
|
@@ -13786,7 +14061,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13786
14061
|
} else {
|
|
13787
14062
|
const selectedIds = hitTestSelection(collectSelectionFeatureGroups(), selectionPolygon);
|
|
13788
14063
|
const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
|
|
13789
|
-
applySelectionState(finalIds, { focusProperties: true });
|
|
14064
|
+
applySelectionState$1(finalIds, { focusProperties: true });
|
|
13790
14065
|
}
|
|
13791
14066
|
setIsSelectionToolActive(false);
|
|
13792
14067
|
setSelectionPoints([]);
|
|
@@ -13902,7 +14177,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13902
14177
|
setSelectionPoints([]);
|
|
13903
14178
|
mapInstance.dragPan.enable();
|
|
13904
14179
|
canvas.style.cursor = "";
|
|
13905
|
-
applySelectionState(mergedIds, { focusProperties: true });
|
|
14180
|
+
applySelectionState$1(mergedIds, { focusProperties: true });
|
|
13906
14181
|
};
|
|
13907
14182
|
canvas.addEventListener("mousedown", handleShiftMouseDown);
|
|
13908
14183
|
window.addEventListener("mousemove", handleShiftMouseMove);
|
|
@@ -13915,7 +14190,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13915
14190
|
map.current.dragPan.enable();
|
|
13916
14191
|
}
|
|
13917
14192
|
};
|
|
13918
|
-
}, [isMapLoaded, isSelectionToolActive, applySelectionState, collectSelectionFeatureGroups]);
|
|
14193
|
+
}, [isMapLoaded, isSelectionToolActive, applySelectionState$1, collectSelectionFeatureGroups]);
|
|
13919
14194
|
useEffect(() => {
|
|
13920
14195
|
if (!map.current || !isMapLoaded) return;
|
|
13921
14196
|
const mapInstance = map.current;
|
|
@@ -15869,8 +16144,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
15869
16144
|
showGoToButton,
|
|
15870
16145
|
onFitToFeatures: handleFitToFeatures,
|
|
15871
16146
|
onDropPoint,
|
|
15872
|
-
|
|
15873
|
-
geocoderProvider,
|
|
16147
|
+
geocoder: endpoints == null ? void 0 : endpoints.geocoder,
|
|
15874
16148
|
onSearchEngineRequest: onSearchEngineRequest ? handleSearchAndAddToNewLayer : void 0,
|
|
15875
16149
|
getAllFeatures,
|
|
15876
16150
|
onFlyToFeature: (feature) => {
|
|
@@ -15990,9 +16264,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
15990
16264
|
onToggle3DTerrain: handleToggle3DTerrain,
|
|
15991
16265
|
onUpdateAltitudeDisplayMode: handleUpdateAltitudeDisplayMode,
|
|
15992
16266
|
availableBasemaps,
|
|
15993
|
-
hideSatellite: !
|
|
15994
|
-
hideDark: !
|
|
15995
|
-
hideTerrain: !
|
|
16267
|
+
hideSatellite: !resolvedEndpoints.satellite,
|
|
16268
|
+
hideDark: !resolvedEndpoints.vectorStyles.dark,
|
|
16269
|
+
hideTerrain: !resolvedEndpoints.terrain,
|
|
15996
16270
|
hideBasemapSwitcher,
|
|
15997
16271
|
externalPersistence,
|
|
15998
16272
|
customGlobalMenuItems,
|