@octostar/map-component 0.6.5 → 0.7.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.mjs +738 -193
- package/dist/index.mjs.map +1 -1
- package/dist/types/components/layers-panel.d.ts +8 -0
- 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/components/properties-panel.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/custom-layer-stack.d.ts +7 -1
- package/dist/types/lib/custom-layer-stack.d.ts.map +1 -1
- package/dist/types/lib/feature-stack.d.ts.map +1 -1
- package/dist/types/lib/host-icon-scale.d.ts +28 -0
- package/dist/types/lib/host-icon-scale.d.ts.map +1 -0
- package/dist/types/lib/host-line-decorations.d.ts +70 -0
- package/dist/types/lib/host-line-decorations.d.ts.map +1 -0
- package/dist/types/lib/host-owned-layers.d.ts +84 -0
- package/dist/types/lib/host-owned-layers.d.ts.map +1 -0
- package/dist/types/lib/label-pinning.d.ts +24 -0
- package/dist/types/lib/label-pinning.d.ts.map +1 -1
- package/dist/types/lib/layer-colors.d.ts +2 -0
- package/dist/types/lib/layer-colors.d.ts.map +1 -1
- package/dist/types/lib/map-editor-api.d.ts +37 -0
- package/dist/types/lib/map-editor-api.d.ts.map +1 -1
- package/dist/types/lib/paint-feature.d.ts +9 -2
- package/dist/types/lib/paint-feature.d.ts.map +1 -1
- package/dist/types/lib/property-utils.d.ts +3 -1
- package/dist/types/lib/property-utils.d.ts.map +1 -1
- package/dist/types/lib/selection-overlay.d.ts +2 -1
- package/dist/types/lib/selection-overlay.d.ts.map +1 -1
- package/dist/types/lib/shard-constants.d.ts +5 -1
- package/dist/types/lib/shard-constants.d.ts.map +1 -1
- package/dist/types/lib/shard-registry.d.ts +2 -0
- package/dist/types/lib/shard-registry.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import proj4 from "proj4";
|
|
|
10
10
|
import { Button, Modal, Input, App, message, ConfigProvider, Tooltip, Dropdown, Divider, Popover, Switch, Slider, Tag, Select, Segmented, DatePicker, Collapse, ColorPicker, Tabs, Card, Table } from "antd";
|
|
11
11
|
import { clsx } from "clsx";
|
|
12
12
|
import { twMerge } from "tailwind-merge";
|
|
13
|
-
import { MousePointer2, Square, Hexagon, Circle, MoreVertical, ChevronDown, Filter, X, Move, Ruler, Search, Scan, Pencil, Database, MapPin, Minus, Pentagon, Type, MoveRight, Undo2, Redo2, Trash2, Navigation, Loader2, Map as Map$1, Satellite, FolderOpen, Upload, Download, MoreHorizontal, Focus, Box, Layers, Plus, ChevronRight, Eye, EyeOff, Lock, Smile, Package, Copy, FolderInput, Save, Calendar, Palette, Blend, RefreshCw, ExternalLink, Info, ChevronLeft, SkipBack, Pause, Play, Clock, AlertTriangle, TestTube, Users, GripVertical, Plane, FileJson, Check, Phone, Car, AlertCircle } from "lucide-react";
|
|
13
|
+
import { MousePointer2, Square, Hexagon, Circle, MoreVertical, ChevronDown, Filter, X, Move, Ruler, Search, Scan, Pencil, Database, MapPin, Minus, Pentagon, Type, MoveRight, Undo2, Redo2, Trash2, Navigation, Loader2, Map as Map$1, Satellite, FolderOpen, Upload, Download, MoreHorizontal, Focus, Box, Layers, Plus, ChevronRight, Eye, EyeOff, Lock, Smile, Package, Copy, FolderInput, Save, Calendar, Palette, Blend, RotateCcw, RefreshCw, ExternalLink, Info, ChevronLeft, SkipBack, Pause, Play, Clock, AlertTriangle, TestTube, Users, GripVertical, Plane, FileJson, Check, Phone, Car, AlertCircle } from "lucide-react";
|
|
14
14
|
import { createPortal } from "react-dom";
|
|
15
15
|
import dayjs from "dayjs";
|
|
16
16
|
import { createStore, useStore } from "zustand";
|
|
@@ -776,6 +776,27 @@ function installInlinedMaplibreWorker() {
|
|
|
776
776
|
}
|
|
777
777
|
setWorkerUrl(URL.createObjectURL(new Blob([maplibreWorkerSource], { type: "text/javascript" })));
|
|
778
778
|
}
|
|
779
|
+
const HOST_ICON_FULL_ZOOM_PROP = "iconFullZoom";
|
|
780
|
+
const HOST_ICON_MIN_ZOOM_PROP = "iconMinZoom";
|
|
781
|
+
const HOST_ICON_MIN_SCALE_PROP = "iconMinScale";
|
|
782
|
+
const ZOOM_STOPS = Array.from({ length: 23 }, (_, z) => z);
|
|
783
|
+
function hostIconScaleAt(z) {
|
|
784
|
+
const full = ["coalesce", ["get", HOST_ICON_FULL_ZOOM_PROP], 0];
|
|
785
|
+
const min = ["coalesce", ["get", HOST_ICON_MIN_ZOOM_PROP], -1];
|
|
786
|
+
const towardsMin = ["max", 0, ["min", 1, ["/", ["-", full, z], ["max", 1e-3, ["-", full, min]]]]];
|
|
787
|
+
return ["^", ["coalesce", ["get", HOST_ICON_MIN_SCALE_PROP], 1], towardsMin];
|
|
788
|
+
}
|
|
789
|
+
function zoomCurve(at) {
|
|
790
|
+
return ["interpolate", ["exponential", 2], ["zoom"], ...ZOOM_STOPS.flatMap((z) => [z, at(z)])];
|
|
791
|
+
}
|
|
792
|
+
const iconSizeAt = (z, canvasSize) => ["*", ["/", ["coalesce", ["get", "iconSize"], 24], canvasSize], hostIconScaleAt(z)];
|
|
793
|
+
function hostIconSizeMultiplier(size, fieldPosition) {
|
|
794
|
+
if ((size == null ? void 0 : size.mode) === "override" && size.overrideValue !== void 0) {
|
|
795
|
+
return 0.5 + Math.max(1, Math.min(10, size.overrideValue)) * 0.1;
|
|
796
|
+
}
|
|
797
|
+
if ((size == null ? void 0 : size.mode) === "field" && fieldPosition !== null) return 0.6 + fieldPosition * 0.9;
|
|
798
|
+
return 1;
|
|
799
|
+
}
|
|
779
800
|
const SELECTED_STATE_KEY = "selected";
|
|
780
801
|
const SELECTED = ["boolean", ["feature-state", SELECTED_STATE_KEY], false];
|
|
781
802
|
const SELECTED_STATE = Object.freeze({ [SELECTED_STATE_KEY]: true });
|
|
@@ -787,6 +808,18 @@ const TRACE_ENDPOINT = ["boolean", ["feature-state", TRACE_ENDPOINT_KEY], false]
|
|
|
787
808
|
const LABEL_NEVER_HIDE_PROP = "_labelNeverHide";
|
|
788
809
|
const PINNED_LABEL_FILTER = ["==", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
789
810
|
const UNPINNED_LABEL_FILTER = ["!=", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
811
|
+
const HOST_OWNED_PROP = "_hostOwned";
|
|
812
|
+
const HOST_FILTER = ["==", ["get", HOST_OWNED_PROP], 1];
|
|
813
|
+
const NOT_HOST_FILTER = ["!=", ["get", HOST_OWNED_PROP], 1];
|
|
814
|
+
const hostIconLabelOffsetAt = (z) => [
|
|
815
|
+
"interpolate",
|
|
816
|
+
["linear"],
|
|
817
|
+
["+", 0.2, ["/", ["*", ["coalesce", ["get", "iconSize"], 24], hostIconScaleAt(z)], ["*", 2, ["coalesce", ["get", "fontSize"], 12]]]],
|
|
818
|
+
0,
|
|
819
|
+
["literal", [0, 0]],
|
|
820
|
+
1e3,
|
|
821
|
+
["literal", [0, 1e3]]
|
|
822
|
+
];
|
|
790
823
|
function computeLabelNeverHide(label) {
|
|
791
824
|
return (label == null ? void 0 : label.neverHide) && !label.hidden ? 1 : 0;
|
|
792
825
|
}
|
|
@@ -852,6 +885,133 @@ function buildCustomLabelPaint(opts) {
|
|
|
852
885
|
"text-opacity": (opts == null ? void 0 : opts.hideSelected) ? ["case", TIMELINE_HIDDEN, 0, SELECTED, 0, visibleOpacity] : visibleOpacity
|
|
853
886
|
};
|
|
854
887
|
}
|
|
888
|
+
function buildHostLabelLayout() {
|
|
889
|
+
const base = buildCustomLabelLayout();
|
|
890
|
+
return {
|
|
891
|
+
...base,
|
|
892
|
+
"text-field": ["case", ["==", ["geometry-type"], "LineString"], "", base["text-field"]],
|
|
893
|
+
"text-size": ["coalesce", ["get", "fontSize"], 12],
|
|
894
|
+
"text-offset": zoomCurve((z) => [
|
|
895
|
+
"case",
|
|
896
|
+
["!=", ["get", "icon"], ""],
|
|
897
|
+
hostIconLabelOffsetAt(z),
|
|
898
|
+
["literal", [0, 0.8]]
|
|
899
|
+
])
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
function buildHostLabelPaint() {
|
|
903
|
+
return { ...buildCustomLabelPaint(), "text-color": ["coalesce", ["get", "fontColor"], "#1f2937"] };
|
|
904
|
+
}
|
|
905
|
+
const CLUSTER_COUNT_VALUE_PROP = "__cluster_count_value";
|
|
906
|
+
const CLUSTER_SUM_PROP = "value_sum";
|
|
907
|
+
const CLUSTER_MEMBER_ID_PROP = "__cluster_fid";
|
|
908
|
+
function clusterCountValue(raw) {
|
|
909
|
+
if (typeof raw === "number") return Number.isFinite(raw) ? raw : 1;
|
|
910
|
+
if (typeof raw === "string" && raw.trim() !== "") {
|
|
911
|
+
const n = Number(raw);
|
|
912
|
+
if (Number.isFinite(n)) return n;
|
|
913
|
+
}
|
|
914
|
+
return 1;
|
|
915
|
+
}
|
|
916
|
+
function injectClusterCountValues(features, fieldName) {
|
|
917
|
+
return features.map((f) => {
|
|
918
|
+
var _a;
|
|
919
|
+
return {
|
|
920
|
+
...f,
|
|
921
|
+
properties: {
|
|
922
|
+
...f.properties,
|
|
923
|
+
[CLUSTER_COUNT_VALUE_PROP]: clusterCountValue((_a = f.properties) == null ? void 0 : _a[fieldName]),
|
|
924
|
+
...f.id != null ? { [CLUSTER_MEMBER_ID_PROP]: String(f.id) } : {}
|
|
925
|
+
}
|
|
926
|
+
};
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
function roundHalfAwayFromZero1(n) {
|
|
930
|
+
return Math.sign(n) * Math.round(Math.abs(n) * 10) / 10;
|
|
931
|
+
}
|
|
932
|
+
function formatClusterBadge(value) {
|
|
933
|
+
if (value >= 1e6) return `${roundHalfAwayFromZero1(value / 1e6)}M`;
|
|
934
|
+
if (value >= 1e3) return `${roundHalfAwayFromZero1(value / 1e3)}k`;
|
|
935
|
+
return String(roundHalfAwayFromZero1(value));
|
|
936
|
+
}
|
|
937
|
+
function clusterBadgeTextField(prop) {
|
|
938
|
+
const value = ["get", prop];
|
|
939
|
+
const round1 = (expr) => ["/", ["round", ["*", expr, 10]], 10];
|
|
940
|
+
return [
|
|
941
|
+
"step",
|
|
942
|
+
value,
|
|
943
|
+
["to-string", round1(value)],
|
|
944
|
+
1e3,
|
|
945
|
+
["concat", ["to-string", round1(["/", value, 1e3])], "k"],
|
|
946
|
+
1e6,
|
|
947
|
+
["concat", ["to-string", round1(["/", value, 1e6])], "M"]
|
|
948
|
+
];
|
|
949
|
+
}
|
|
950
|
+
const FILL_PICKED_PROP = "fillPicked";
|
|
951
|
+
const INTERNAL_PROPERTY_KEYS = /* @__PURE__ */ new Set([
|
|
952
|
+
"fill",
|
|
953
|
+
"fill-opacity",
|
|
954
|
+
"pointRadius",
|
|
955
|
+
"pointIcon",
|
|
956
|
+
"pointIconSize",
|
|
957
|
+
"circleCenter",
|
|
958
|
+
"circleRadius",
|
|
959
|
+
"icon",
|
|
960
|
+
"iconSize",
|
|
961
|
+
"fontSize",
|
|
962
|
+
"fontColor",
|
|
963
|
+
"fontWeight",
|
|
964
|
+
"arrowSize",
|
|
965
|
+
"arrowInset",
|
|
966
|
+
"iconFullZoom",
|
|
967
|
+
"iconMinZoom",
|
|
968
|
+
"iconMinScale",
|
|
969
|
+
"label",
|
|
970
|
+
"entityType",
|
|
971
|
+
"kind",
|
|
972
|
+
"meta:type",
|
|
973
|
+
"stroke",
|
|
974
|
+
"stroke-width",
|
|
975
|
+
"stroke-opacity",
|
|
976
|
+
FILL_PICKED_PROP,
|
|
977
|
+
CLUSTER_COUNT_VALUE_PROP,
|
|
978
|
+
CLUSTER_MEMBER_ID_PROP
|
|
979
|
+
]);
|
|
980
|
+
const STYLING_PROPERTY_KEYS = [
|
|
981
|
+
"stroke",
|
|
982
|
+
"stroke-width",
|
|
983
|
+
"stroke-opacity",
|
|
984
|
+
"fill",
|
|
985
|
+
"fill-opacity",
|
|
986
|
+
FILL_PICKED_PROP,
|
|
987
|
+
"pointRadius",
|
|
988
|
+
"pointIcon",
|
|
989
|
+
"pointIconSize",
|
|
990
|
+
"icon",
|
|
991
|
+
"iconSize",
|
|
992
|
+
"circleCenter",
|
|
993
|
+
"circleRadius",
|
|
994
|
+
"fontSize",
|
|
995
|
+
"fontColor",
|
|
996
|
+
"fontWeight",
|
|
997
|
+
"arrowSize",
|
|
998
|
+
"arrowInset",
|
|
999
|
+
"iconFullZoom",
|
|
1000
|
+
"iconMinZoom",
|
|
1001
|
+
"iconMinScale"
|
|
1002
|
+
];
|
|
1003
|
+
const INTERNAL_PROPERTY_PREFIXES = [
|
|
1004
|
+
"IsHiddenBy",
|
|
1005
|
+
"isHidden",
|
|
1006
|
+
"isSelected",
|
|
1007
|
+
"isTrace",
|
|
1008
|
+
"isTimeline",
|
|
1009
|
+
"trace"
|
|
1010
|
+
];
|
|
1011
|
+
function isInternalProperty(key) {
|
|
1012
|
+
if (INTERNAL_PROPERTY_KEYS.has(key)) return true;
|
|
1013
|
+
return INTERNAL_PROPERTY_PREFIXES.some((prefix) => key.startsWith(prefix));
|
|
1014
|
+
}
|
|
855
1015
|
const DEFAULT_FEATURE_COLOR = "#3b82f6";
|
|
856
1016
|
const LAYER_COLOR_PALETTE = [
|
|
857
1017
|
"#3FB37F",
|
|
@@ -892,10 +1052,14 @@ function pickLayerColor(layers) {
|
|
|
892
1052
|
}
|
|
893
1053
|
return best;
|
|
894
1054
|
}
|
|
1055
|
+
function ownFill(properties) {
|
|
1056
|
+
const fill = properties == null ? void 0 : properties.fill;
|
|
1057
|
+
return (properties == null ? void 0 : properties[FILL_PICKED_PROP]) === true && typeof fill === "string" && fill !== "" ? fill : void 0;
|
|
1058
|
+
}
|
|
1059
|
+
const isOwnColor = (color) => typeof color === "string" && color !== "" && color.toLowerCase() !== DEFAULT_FEATURE_COLOR;
|
|
895
1060
|
function carriesOwnColor(feature) {
|
|
896
1061
|
var _a;
|
|
897
|
-
|
|
898
|
-
return typeof stroke === "string" && stroke !== "" && stroke.toLowerCase() !== DEFAULT_FEATURE_COLOR;
|
|
1062
|
+
return isOwnColor((_a = feature.properties) == null ? void 0 : _a.stroke) || isOwnColor(ownFill(feature.properties));
|
|
899
1063
|
}
|
|
900
1064
|
function withAutoLayerColor(layer, features, existing) {
|
|
901
1065
|
var _a;
|
|
@@ -912,8 +1076,10 @@ const CUSTOM_LAYER_ROLES = [
|
|
|
912
1076
|
"point-shadow",
|
|
913
1077
|
"point",
|
|
914
1078
|
"point-icon",
|
|
1079
|
+
"host-icon",
|
|
915
1080
|
"labels",
|
|
916
|
-
"labels-pinned"
|
|
1081
|
+
"labels-pinned",
|
|
1082
|
+
"host-labels"
|
|
917
1083
|
];
|
|
918
1084
|
const SHARED_SOURCE_ID = "custom-features";
|
|
919
1085
|
function customSourceSpec() {
|
|
@@ -970,6 +1136,11 @@ function shardInsertAnchor(role) {
|
|
|
970
1136
|
return "custom-arrow-heads";
|
|
971
1137
|
case "labels-pinned":
|
|
972
1138
|
return "custom-arrow-heads";
|
|
1139
|
+
// Never in a shard stack: host-owned layers are not sharded.
|
|
1140
|
+
case "host-icon":
|
|
1141
|
+
return "custom-arrow-heads";
|
|
1142
|
+
case "host-labels":
|
|
1143
|
+
return "custom-arrow-heads";
|
|
973
1144
|
}
|
|
974
1145
|
}
|
|
975
1146
|
const POINT_RADIUS = ["case", TRACE_ENDPOINT, ["get", "_endpointRadius"], ["coalesce", ["get", "pointRadius"], 5]];
|
|
@@ -978,6 +1149,7 @@ function unlessTimelineHidden(value) {
|
|
|
978
1149
|
}
|
|
979
1150
|
function buildLayer(role, sourceId, opts) {
|
|
980
1151
|
const id = customLayerId(role, sourceId);
|
|
1152
|
+
const shared = sourceId === SHARED_SOURCE_ID;
|
|
981
1153
|
switch (role) {
|
|
982
1154
|
// Custom polygon fill layer - preserves original styling
|
|
983
1155
|
case "polygon-fill":
|
|
@@ -1116,7 +1288,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1116
1288
|
id,
|
|
1117
1289
|
type: "symbol",
|
|
1118
1290
|
source: sourceId,
|
|
1119
|
-
filter: ["all", ["==", "$type", "Point"], ["!=", "icon", ""]],
|
|
1291
|
+
filter: shared ? ["all", ["==", "$type", "Point"], ["!=", "icon", ""], ["!=", HOST_OWNED_PROP, 1]] : ["all", ["==", "$type", "Point"], ["!=", "icon", ""]],
|
|
1120
1292
|
layout: {
|
|
1121
1293
|
"icon-image": ["get", "icon"],
|
|
1122
1294
|
"icon-size": ["/", ["coalesce", ["get", "iconSize"], 24], EMOJI_CANVAS_SIZE],
|
|
@@ -1146,7 +1318,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1146
1318
|
id,
|
|
1147
1319
|
type: "symbol",
|
|
1148
1320
|
source: sourceId,
|
|
1149
|
-
filter: UNPINNED_LABEL_FILTER,
|
|
1321
|
+
filter: shared ? ["all", UNPINNED_LABEL_FILTER, NOT_HOST_FILTER] : UNPINNED_LABEL_FILTER,
|
|
1150
1322
|
layout: {
|
|
1151
1323
|
...buildCustomLabelLayout(),
|
|
1152
1324
|
"visibility": opts.labelsVisible ? "visible" : "none",
|
|
@@ -1198,7 +1370,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1198
1370
|
id,
|
|
1199
1371
|
type: "symbol",
|
|
1200
1372
|
source: sourceId,
|
|
1201
|
-
filter: PINNED_LABEL_FILTER,
|
|
1373
|
+
filter: shared ? ["all", PINNED_LABEL_FILTER, NOT_HOST_FILTER] : PINNED_LABEL_FILTER,
|
|
1202
1374
|
layout: {
|
|
1203
1375
|
...buildCustomLabelLayout(),
|
|
1204
1376
|
"visibility": "visible",
|
|
@@ -1211,6 +1383,29 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1211
1383
|
},
|
|
1212
1384
|
paint: buildCustomLabelPaint({ hideSelected: true })
|
|
1213
1385
|
};
|
|
1386
|
+
// A host point's icon, scaled along the host's zoom curve. The only
|
|
1387
|
+
// icon layer a pointer can hit, while a host-owned layer exists.
|
|
1388
|
+
case "host-icon": {
|
|
1389
|
+
const icon = buildLayer("point-icon", sourceId, opts);
|
|
1390
|
+
return {
|
|
1391
|
+
...icon,
|
|
1392
|
+
id,
|
|
1393
|
+
filter: ["all", ["==", "$type", "Point"], ["!=", "icon", ""], ["==", HOST_OWNED_PROP, 1]],
|
|
1394
|
+
layout: { ...icon.layout, "icon-size": zoomCurve((z) => iconSizeAt(z, EMOJI_CANVAS_SIZE)) }
|
|
1395
|
+
};
|
|
1396
|
+
}
|
|
1397
|
+
// Host labels: collision-culled and density-hidden like `labels`, styled
|
|
1398
|
+
// by the host (label-pinning.ts). A host layer's "never hide" is not honoured.
|
|
1399
|
+
case "host-labels": {
|
|
1400
|
+
const labels = buildLayer("labels", sourceId, opts);
|
|
1401
|
+
return {
|
|
1402
|
+
...labels,
|
|
1403
|
+
id,
|
|
1404
|
+
filter: HOST_FILTER,
|
|
1405
|
+
layout: { ...labels.layout, ...buildHostLabelLayout() },
|
|
1406
|
+
paint: buildHostLabelPaint()
|
|
1407
|
+
};
|
|
1408
|
+
}
|
|
1214
1409
|
}
|
|
1215
1410
|
}
|
|
1216
1411
|
function buildCustomLayerStack(sourceId, roles, opts) {
|
|
@@ -1221,6 +1416,7 @@ function isShardEligible(layer, featureCount, shardSize) {
|
|
|
1221
1416
|
var _a;
|
|
1222
1417
|
if (!layer.readOnly) return false;
|
|
1223
1418
|
if ((_a = layer.traceConfig) == null ? void 0 : _a.enabled) return false;
|
|
1419
|
+
if (layer.hostOwned) return false;
|
|
1224
1420
|
if (!isUsableShardSize(shardSize)) return false;
|
|
1225
1421
|
return featureCount > shardSize;
|
|
1226
1422
|
}
|
|
@@ -1276,6 +1472,7 @@ function shardFingerprintsEqual(a, b) {
|
|
|
1276
1472
|
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);
|
|
1277
1473
|
}
|
|
1278
1474
|
const INTERACTIVE_ROLES = ["point", "line", "polygon-fill"];
|
|
1475
|
+
const HOST_INTERACTIVE_ROLES = [...INTERACTIVE_ROLES, "host-icon"];
|
|
1279
1476
|
function createShardRegistry(host, hooks) {
|
|
1280
1477
|
const states = /* @__PURE__ */ new Map();
|
|
1281
1478
|
let sharedLayerIds = [];
|
|
@@ -1397,7 +1594,8 @@ function createShardRegistry(host, hooks) {
|
|
|
1397
1594
|
},
|
|
1398
1595
|
labelLayerIds(kind, opts) {
|
|
1399
1596
|
const roles = kind === "unpinned" ? ["labels"] : kind === "pinned" ? ["labels-pinned"] : ["labels", "labels-pinned"];
|
|
1400
|
-
const
|
|
1597
|
+
const sharedRoles = kind === "pinned" ? roles : [...roles, "host-labels"];
|
|
1598
|
+
const ids = sharedLayerIds.filter((id) => sharedRoles.some((role) => id === customLayerId(role, SHARED_SOURCE_ID)));
|
|
1401
1599
|
states.forEach((state) => {
|
|
1402
1600
|
if ((opts == null ? void 0 : opts.visibleLayersOnly) && !state.visible) return;
|
|
1403
1601
|
state.stacks.forEach((stack) => {
|
|
@@ -1410,8 +1608,10 @@ function createShardRegistry(host, hooks) {
|
|
|
1410
1608
|
return ids;
|
|
1411
1609
|
},
|
|
1412
1610
|
interactiveLayerIds() {
|
|
1611
|
+
var _a;
|
|
1612
|
+
const sharedRoles = ((_a = hooks.hostIconInteractive) == null ? void 0 : _a.call(hooks)) ? HOST_INTERACTIVE_ROLES : INTERACTIVE_ROLES;
|
|
1413
1613
|
const ids = sharedLayerIds.filter(
|
|
1414
|
-
(id) =>
|
|
1614
|
+
(id) => sharedRoles.some((role) => id === customLayerId(role, SHARED_SOURCE_ID))
|
|
1415
1615
|
);
|
|
1416
1616
|
states.forEach((state) => {
|
|
1417
1617
|
if (!state.visible) return;
|
|
@@ -1544,6 +1744,79 @@ function formatGradientStop(value) {
|
|
|
1544
1744
|
}
|
|
1545
1745
|
return new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 }).format(value);
|
|
1546
1746
|
}
|
|
1747
|
+
const HOST_IMAGE_PREFIX = "host:";
|
|
1748
|
+
function isHostOwnedLayer(layer) {
|
|
1749
|
+
return (layer == null ? void 0 : layer.hostOwned) === true;
|
|
1750
|
+
}
|
|
1751
|
+
function isHistoryExcludedLayer(layer) {
|
|
1752
|
+
var _a;
|
|
1753
|
+
return ((_a = layer == null ? void 0 : layer.metadata) == null ? void 0 : _a.dataViewing) === true || isHostOwnedLayer(layer);
|
|
1754
|
+
}
|
|
1755
|
+
function keepLayerAfterFeatureRemoval(layer) {
|
|
1756
|
+
return layer.featureIds.length > 0 || !layer.readOnly || isHostOwnedLayer(layer);
|
|
1757
|
+
}
|
|
1758
|
+
function showsPropertiesFor(ids, layers) {
|
|
1759
|
+
if (ids.length === 0) return false;
|
|
1760
|
+
const hostIds = new Set(layers.filter(isHostOwnedLayer).flatMap((l) => l.featureIds));
|
|
1761
|
+
return ids.some((id) => !hostIds.has(id));
|
|
1762
|
+
}
|
|
1763
|
+
function splitDeleteByOwner(layers, ids) {
|
|
1764
|
+
const hostLayerOf = /* @__PURE__ */ new Map();
|
|
1765
|
+
for (const layer of layers) {
|
|
1766
|
+
if (!isHostOwnedLayer(layer)) continue;
|
|
1767
|
+
for (const fid of layer.featureIds) hostLayerOf.set(fid, layer.id);
|
|
1768
|
+
}
|
|
1769
|
+
const deletableIds = [];
|
|
1770
|
+
const byLayer = /* @__PURE__ */ new Map();
|
|
1771
|
+
for (const id of ids) {
|
|
1772
|
+
const layerId = hostLayerOf.get(id);
|
|
1773
|
+
if (layerId === void 0) {
|
|
1774
|
+
deletableIds.push(id);
|
|
1775
|
+
continue;
|
|
1776
|
+
}
|
|
1777
|
+
const list = byLayer.get(layerId);
|
|
1778
|
+
if (list) list.push(id);
|
|
1779
|
+
else byLayer.set(layerId, [id]);
|
|
1780
|
+
}
|
|
1781
|
+
const hostRequests = [];
|
|
1782
|
+
for (const layer of layers) {
|
|
1783
|
+
const featureIds = byLayer.get(layer.id);
|
|
1784
|
+
if (featureIds) hostRequests.push({ layerId: layer.id, featureIds });
|
|
1785
|
+
}
|
|
1786
|
+
return { deletableIds, hostRequests };
|
|
1787
|
+
}
|
|
1788
|
+
function movableFeatureIds(layers, ids, targetLayerId) {
|
|
1789
|
+
if (targetLayerId !== void 0 && isHostOwnedLayer(layers.find((l) => l.id === targetLayerId))) return [];
|
|
1790
|
+
return splitDeleteByOwner(layers, ids).deletableIds;
|
|
1791
|
+
}
|
|
1792
|
+
function isHostDeleteUndo(value) {
|
|
1793
|
+
return typeof (value == null ? void 0 : value.undo) === "function" && typeof (value == null ? void 0 : value.redo) === "function";
|
|
1794
|
+
}
|
|
1795
|
+
function withHostDeleteUndos(base, label, hostUndos) {
|
|
1796
|
+
if (hostUndos.length === 0) return base;
|
|
1797
|
+
return {
|
|
1798
|
+
...base,
|
|
1799
|
+
label: (base == null ? void 0 : base.label) ?? label,
|
|
1800
|
+
undo: () => {
|
|
1801
|
+
base == null ? void 0 : base.undo();
|
|
1802
|
+
hostUndos.forEach((h) => h.undo());
|
|
1803
|
+
},
|
|
1804
|
+
redo: () => {
|
|
1805
|
+
base == null ? void 0 : base.redo();
|
|
1806
|
+
hostUndos.forEach((h) => h.redo());
|
|
1807
|
+
}
|
|
1808
|
+
};
|
|
1809
|
+
}
|
|
1810
|
+
function resolveMissingImage(id, provider) {
|
|
1811
|
+
let image = null;
|
|
1812
|
+
try {
|
|
1813
|
+
image = provider == null ? void 0 : provider(id);
|
|
1814
|
+
} catch {
|
|
1815
|
+
image = null;
|
|
1816
|
+
}
|
|
1817
|
+
if (image == null ? void 0 : image.data) return { kind: "host", image };
|
|
1818
|
+
return id.startsWith(HOST_IMAGE_PREFIX) ? { kind: "none" } : { kind: "emoji" };
|
|
1819
|
+
}
|
|
1547
1820
|
const ICONS = [
|
|
1548
1821
|
// Location & Places
|
|
1549
1822
|
{ id: "map-pin", emoji: "📍", name: "Map Pin", category: "places" },
|
|
@@ -2165,6 +2438,11 @@ const DEFAULT_LABEL_PRIORITY = 100;
|
|
|
2165
2438
|
const DEFAULT_VISIBLE_STROKE_OPACITY = 1;
|
|
2166
2439
|
const DEFAULT_VISIBLE_FILL_OPACITY = 0.2;
|
|
2167
2440
|
const RENDER_PASSTHROUGH_KEYS = ["_dvl_h3"];
|
|
2441
|
+
const HOST_PASSTHROUGH_KEYS = [
|
|
2442
|
+
HOST_ICON_FULL_ZOOM_PROP,
|
|
2443
|
+
HOST_ICON_MIN_ZOOM_PROP,
|
|
2444
|
+
HOST_ICON_MIN_SCALE_PROP
|
|
2445
|
+
];
|
|
2168
2446
|
const ANNOTATION_PASSTHROUGH_KEYS = [
|
|
2169
2447
|
"kind",
|
|
2170
2448
|
"text",
|
|
@@ -2193,7 +2471,7 @@ function resolveIcon(value) {
|
|
|
2193
2471
|
if (typeof value !== "string" || value === "") return "";
|
|
2194
2472
|
if (value !== lastIcon) {
|
|
2195
2473
|
lastIcon = value;
|
|
2196
|
-
lastResolvedIcon = isEmojiIcon(value) ? value : EMOJI_BY_ID.get(value) ?? "";
|
|
2474
|
+
lastResolvedIcon = value.startsWith(HOST_IMAGE_PREFIX) || isEmojiIcon(value) ? value : EMOJI_BY_ID.get(value) ?? "";
|
|
2197
2475
|
}
|
|
2198
2476
|
return lastResolvedIcon;
|
|
2199
2477
|
}
|
|
@@ -2208,38 +2486,39 @@ const clusterHidesPoints = (layer) => {
|
|
|
2208
2486
|
function layerHidesPoints(layer) {
|
|
2209
2487
|
return heatmapHidesPoints(layer) || clusterHidesPoints(layer);
|
|
2210
2488
|
}
|
|
2489
|
+
function sizeFieldPosition(f, layer, ctx) {
|
|
2490
|
+
var _a, _b;
|
|
2491
|
+
const size = (_a = layer == null ? void 0 : layer.visualConfig) == null ? void 0 : _a.size;
|
|
2492
|
+
if (!layer || (size == null ? void 0 : size.mode) !== "field" || !size.fieldName) return null;
|
|
2493
|
+
const range = ctx.sizeFieldRanges.get(layer.id);
|
|
2494
|
+
if (!range) return null;
|
|
2495
|
+
const val = coerceFiniteNumber((_b = f.properties) == null ? void 0 : _b[size.fieldName]);
|
|
2496
|
+
if (val === null) return null;
|
|
2497
|
+
return range.max > range.min ? (val - range.min) / (range.max - range.min) : 0.5;
|
|
2498
|
+
}
|
|
2211
2499
|
function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
2212
2500
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
2213
2501
|
const featureId = String(f.id);
|
|
2214
2502
|
const visualConfig = layer == null ? void 0 : layer.visualConfig;
|
|
2215
2503
|
const baseOpacity = ((_a = f.properties) == null ? void 0 : _a["stroke-opacity"]) ?? DEFAULT_VISIBLE_STROKE_OPACITY;
|
|
2216
|
-
let strokeColor = ((_b = f.properties) == null ? void 0 : _b.stroke) || DEFAULT_FEATURE_COLOR;
|
|
2217
2504
|
const colorConfig = visualConfig == null ? void 0 : visualConfig.color;
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
colorConfig,
|
|
2221
|
-
f.properties,
|
|
2222
|
-
strokeColor,
|
|
2223
|
-
layer ? ctx.colorFieldRanges.get(layer.id) : void 0
|
|
2224
|
-
);
|
|
2225
|
-
}
|
|
2505
|
+
const layerColor = colorConfig ? resolveFeatureColor(colorConfig, f.properties, "", layer ? ctx.colorFieldRanges.get(layer.id) : void 0) : "";
|
|
2506
|
+
let strokeColor = layerColor || ((_b = f.properties) == null ? void 0 : _b.stroke) || DEFAULT_FEATURE_COLOR;
|
|
2226
2507
|
let strokeWidth = ((_c = f.properties) == null ? void 0 : _c["stroke-width"]) || 2;
|
|
2227
2508
|
let pointRadius = Math.round(3 + strokeWidth);
|
|
2228
2509
|
const sizeConfig = visualConfig == null ? void 0 : visualConfig.size;
|
|
2229
|
-
|
|
2510
|
+
const hostSizeMultiplier = (layer == null ? void 0 : layer.hostOwned) ? hostIconSizeMultiplier(sizeConfig, sizeFieldPosition(f, layer, ctx)) : null;
|
|
2511
|
+
if (hostSizeMultiplier !== null) {
|
|
2512
|
+
strokeWidth *= hostSizeMultiplier;
|
|
2513
|
+
} else if (sizeConfig) {
|
|
2230
2514
|
if (sizeConfig.mode === "override" && sizeConfig.overrideValue !== void 0) {
|
|
2231
2515
|
strokeWidth = Math.max(1, Math.min(10, sizeConfig.overrideValue));
|
|
2232
2516
|
pointRadius = Math.round(3 + strokeWidth);
|
|
2233
|
-
} else
|
|
2234
|
-
const
|
|
2235
|
-
if (
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
if (isFinite(val)) {
|
|
2239
|
-
const normalized = range.max > range.min ? (val - range.min) / (range.max - range.min) : 0.5;
|
|
2240
|
-
strokeWidth = 2 + normalized * 8;
|
|
2241
|
-
pointRadius = Math.round(2 + normalized * 16);
|
|
2242
|
-
}
|
|
2517
|
+
} else {
|
|
2518
|
+
const pos = sizeFieldPosition(f, layer, ctx);
|
|
2519
|
+
if (pos !== null) {
|
|
2520
|
+
strokeWidth = 2 + pos * 8;
|
|
2521
|
+
pointRadius = Math.round(2 + pos * 16);
|
|
2243
2522
|
}
|
|
2244
2523
|
}
|
|
2245
2524
|
}
|
|
@@ -2263,7 +2542,9 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
2263
2542
|
}
|
|
2264
2543
|
}
|
|
2265
2544
|
let featureIcon = resolveIcon(((_e = f.properties) == null ? void 0 : _e.pointIcon) || ((_f = f.properties) == null ? void 0 : _f.icon));
|
|
2545
|
+
if (featureIcon.startsWith(HOST_IMAGE_PREFIX) && !isHostOwnedLayer(layer)) featureIcon = "";
|
|
2266
2546
|
let featureIconSize = ((_g = f.properties) == null ? void 0 : _g.pointIconSize) || ((_h = f.properties) == null ? void 0 : _h.iconSize) || 24;
|
|
2547
|
+
if (hostSizeMultiplier !== null) featureIconSize *= hostSizeMultiplier;
|
|
2267
2548
|
const iconConfig = visualConfig == null ? void 0 : visualConfig.icon;
|
|
2268
2549
|
const layerIcon = !featureIcon && (iconConfig == null ? void 0 : iconConfig.enabled) ? resolveIcon(iconConfig.icon) : "";
|
|
2269
2550
|
if (layerIcon) {
|
|
@@ -2282,7 +2563,12 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
2282
2563
|
RENDER_PASSTHROUGH_KEYS.forEach((key) => {
|
|
2283
2564
|
if (key in props) sanitizedProps[key] = sanitizeValue(props[key]);
|
|
2284
2565
|
});
|
|
2285
|
-
if (
|
|
2566
|
+
if (layer == null ? void 0 : layer.hostOwned) {
|
|
2567
|
+
HOST_PASSTHROUGH_KEYS.forEach((key) => {
|
|
2568
|
+
if (key in props) sanitizedProps[key] = sanitizeValue(props[key]);
|
|
2569
|
+
});
|
|
2570
|
+
}
|
|
2571
|
+
if (typeof props.kind === "string" || (layer == null ? void 0 : layer.hostOwned)) {
|
|
2286
2572
|
ANNOTATION_PASSTHROUGH_KEYS.forEach((key) => {
|
|
2287
2573
|
if (key in props) sanitizedProps[key] = sanitizeValue(props[key]);
|
|
2288
2574
|
});
|
|
@@ -2307,7 +2593,7 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
2307
2593
|
}
|
|
2308
2594
|
const visibleStrokeOpacity = hideFlatFor3DOnly ? 0 : baseOpacity;
|
|
2309
2595
|
const visibleFillOpacity = hideFlatFor3DOnly ? 0 : ((_k = f.properties) == null ? void 0 : _k["fill-opacity"]) ?? DEFAULT_VISIBLE_FILL_OPACITY;
|
|
2310
|
-
|
|
2596
|
+
const styled = {
|
|
2311
2597
|
feature: {
|
|
2312
2598
|
type: "Feature",
|
|
2313
2599
|
id: featureId,
|
|
@@ -2327,7 +2613,7 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
2327
2613
|
stroke: strokeColor,
|
|
2328
2614
|
"stroke-width": strokeWidth,
|
|
2329
2615
|
"stroke-opacity": visibleStrokeOpacity,
|
|
2330
|
-
fill: strokeColor,
|
|
2616
|
+
fill: layerColor ? strokeColor : ownFill(f.properties) ?? strokeColor,
|
|
2331
2617
|
"fill-opacity": visibleFillOpacity,
|
|
2332
2618
|
pointRadius,
|
|
2333
2619
|
_labelPriority: labelPriority2,
|
|
@@ -2335,6 +2621,8 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
2335
2621
|
}
|
|
2336
2622
|
}
|
|
2337
2623
|
};
|
|
2624
|
+
if (layer == null ? void 0 : layer.hostOwned) styled.feature.properties[HOST_OWNED_PROP] = 1;
|
|
2625
|
+
return styled;
|
|
2338
2626
|
}
|
|
2339
2627
|
function layerFieldRanges(visualConfig, forEachProperties) {
|
|
2340
2628
|
const sizeConfig = visualConfig == null ? void 0 : visualConfig.size;
|
|
@@ -2432,6 +2720,224 @@ function frameYield(scheduler = defaultScheduler, fallbackMs = 50) {
|
|
|
2432
2720
|
}, fallbackMs);
|
|
2433
2721
|
});
|
|
2434
2722
|
}
|
|
2723
|
+
const HOST_DECORATION_SOURCE_ID = "host-line-decorations";
|
|
2724
|
+
const HOST_DECORATION_LAYER_IDS = {
|
|
2725
|
+
arrowheads: "custom-host-arrowheads",
|
|
2726
|
+
labels: "custom-host-line-labels"
|
|
2727
|
+
};
|
|
2728
|
+
const ARROWHEAD_IMAGE_ID = "octostar:arrowhead";
|
|
2729
|
+
const ARROWHEAD_LENGTH = 12;
|
|
2730
|
+
const ARROWHEAD_WIDTH = 10;
|
|
2731
|
+
const ARROWHEAD_BUFFER = 3;
|
|
2732
|
+
function arrowheadScale(strokeWidth) {
|
|
2733
|
+
const width = typeof strokeWidth === "number" && isFinite(strokeWidth) ? strokeWidth : 2;
|
|
2734
|
+
return Math.max(1, width / 2);
|
|
2735
|
+
}
|
|
2736
|
+
const DEG = Math.PI / 180;
|
|
2737
|
+
function toMercator([lng, lat]) {
|
|
2738
|
+
const clamped = Math.max(-85.0511, Math.min(85.0511, lat));
|
|
2739
|
+
return [lng * DEG, Math.log(Math.tan(Math.PI / 4 + clamped * DEG / 2))];
|
|
2740
|
+
}
|
|
2741
|
+
function fromMercator([x, y]) {
|
|
2742
|
+
return [x / DEG, (2 * Math.atan(Math.exp(y)) - Math.PI / 2) / DEG];
|
|
2743
|
+
}
|
|
2744
|
+
function segmentBearing(from, to) {
|
|
2745
|
+
const [x0, y0] = toMercator(from);
|
|
2746
|
+
const [x1, y1] = toMercator(to);
|
|
2747
|
+
return Math.atan2(x1 - x0, y1 - y0) / DEG;
|
|
2748
|
+
}
|
|
2749
|
+
function labelRotationForBearing(bearing) {
|
|
2750
|
+
let r = bearing - 90;
|
|
2751
|
+
r = (r % 360 + 540) % 360 - 180;
|
|
2752
|
+
if (r > 90) r -= 180;
|
|
2753
|
+
else if (r < -90) r += 180;
|
|
2754
|
+
return r;
|
|
2755
|
+
}
|
|
2756
|
+
function lineMidpoint(coords) {
|
|
2757
|
+
if (coords.length < 2) return null;
|
|
2758
|
+
const projected = coords.map(toMercator);
|
|
2759
|
+
const lengths = [];
|
|
2760
|
+
let total = 0;
|
|
2761
|
+
for (let i = 1; i < projected.length; i++) {
|
|
2762
|
+
const len = Math.hypot(projected[i][0] - projected[i - 1][0], projected[i][1] - projected[i - 1][1]);
|
|
2763
|
+
lengths.push(len);
|
|
2764
|
+
total += len;
|
|
2765
|
+
}
|
|
2766
|
+
if (total === 0) return null;
|
|
2767
|
+
let remaining = total / 2;
|
|
2768
|
+
for (let i = 0; i < lengths.length; i++) {
|
|
2769
|
+
if (remaining <= lengths[i] || i === lengths.length - 1) {
|
|
2770
|
+
const t = lengths[i] === 0 ? 0 : Math.min(1, remaining / lengths[i]);
|
|
2771
|
+
const a = projected[i];
|
|
2772
|
+
const b = projected[i + 1];
|
|
2773
|
+
return {
|
|
2774
|
+
point: fromMercator([a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t]),
|
|
2775
|
+
bearing: segmentBearing(coords[i], coords[i + 1])
|
|
2776
|
+
};
|
|
2777
|
+
}
|
|
2778
|
+
remaining -= lengths[i];
|
|
2779
|
+
}
|
|
2780
|
+
return null;
|
|
2781
|
+
}
|
|
2782
|
+
function buildHostLineDecorations(lines) {
|
|
2783
|
+
var _a, _b, _c, _d;
|
|
2784
|
+
const out = [];
|
|
2785
|
+
for (const { styled, record } of lines) {
|
|
2786
|
+
if (((_a = styled.geometry) == null ? void 0 : _a.type) !== "LineString") continue;
|
|
2787
|
+
const coords = styled.geometry.coordinates;
|
|
2788
|
+
if (coords.length < 2) continue;
|
|
2789
|
+
const props = styled.properties ?? {};
|
|
2790
|
+
const opacity = props["stroke-opacity"] ?? 1;
|
|
2791
|
+
const name = props.name;
|
|
2792
|
+
if (typeof name === "string" && name !== "") {
|
|
2793
|
+
const mid = lineMidpoint(coords);
|
|
2794
|
+
if (mid) {
|
|
2795
|
+
out.push({
|
|
2796
|
+
type: "Feature",
|
|
2797
|
+
geometry: { type: "Point", coordinates: mid.point },
|
|
2798
|
+
properties: {
|
|
2799
|
+
role: "label",
|
|
2800
|
+
name,
|
|
2801
|
+
fontColor: props.fontColor ?? null,
|
|
2802
|
+
fontSize: props.fontSize ?? null,
|
|
2803
|
+
"stroke-opacity": opacity,
|
|
2804
|
+
labelRotate: labelRotationForBearing(mid.bearing)
|
|
2805
|
+
}
|
|
2806
|
+
});
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2809
|
+
if (((_b = record.properties) == null ? void 0 : _b.kind) === "arrow") {
|
|
2810
|
+
const end = coords[coords.length - 1];
|
|
2811
|
+
let i = coords.length - 2;
|
|
2812
|
+
while (i > 0 && coords[i][0] === end[0] && coords[i][1] === end[1]) i--;
|
|
2813
|
+
const prev = coords[i];
|
|
2814
|
+
if (prev[0] === end[0] && prev[1] === end[1]) continue;
|
|
2815
|
+
const scale = arrowheadScale(props["stroke-width"]);
|
|
2816
|
+
const insetRaw = (_c = record.properties) == null ? void 0 : _c.arrowInset;
|
|
2817
|
+
const storedWidth = Number((_d = record.properties) == null ? void 0 : _d["stroke-width"]) || 2;
|
|
2818
|
+
const sizeFactor = typeof props["stroke-width"] === "number" ? props["stroke-width"] / storedWidth : 1;
|
|
2819
|
+
const inset = typeof insetRaw === "number" && isFinite(insetRaw) && insetRaw > 0 ? insetRaw * sizeFactor : 0;
|
|
2820
|
+
out.push({
|
|
2821
|
+
type: "Feature",
|
|
2822
|
+
geometry: { type: "Point", coordinates: [end[0], end[1]] },
|
|
2823
|
+
properties: {
|
|
2824
|
+
role: "arrow",
|
|
2825
|
+
stroke: props.stroke ?? null,
|
|
2826
|
+
"stroke-opacity": opacity,
|
|
2827
|
+
arrowBearing: segmentBearing(prev, end),
|
|
2828
|
+
arrowScale: scale,
|
|
2829
|
+
// `icon-offset` is in icon-size units: the head's own half length,
|
|
2830
|
+
// plus the inset in pixels divided back out of the scale. The inset is
|
|
2831
|
+
// the end node's radius, so it shrinks with that node's icon.
|
|
2832
|
+
arrowHeadOffset: ARROWHEAD_LENGTH / 2,
|
|
2833
|
+
arrowInsetOffset: inset / scale,
|
|
2834
|
+
...hostIconScaleProps(record.properties)
|
|
2835
|
+
}
|
|
2836
|
+
});
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2839
|
+
return out;
|
|
2840
|
+
}
|
|
2841
|
+
const offsetAlongYAt = (z) => [
|
|
2842
|
+
"interpolate",
|
|
2843
|
+
["linear"],
|
|
2844
|
+
["+", ["coalesce", ["get", "arrowHeadOffset"], 0], ["*", ["coalesce", ["get", "arrowInsetOffset"], 0], hostIconScaleAt(z)]],
|
|
2845
|
+
0,
|
|
2846
|
+
["literal", [0, 0]],
|
|
2847
|
+
1e5,
|
|
2848
|
+
["literal", [0, 1e5]]
|
|
2849
|
+
];
|
|
2850
|
+
function hostIconScaleProps(props) {
|
|
2851
|
+
const out = {};
|
|
2852
|
+
for (const key of [HOST_ICON_FULL_ZOOM_PROP, HOST_ICON_MIN_ZOOM_PROP, HOST_ICON_MIN_SCALE_PROP]) {
|
|
2853
|
+
const value = props == null ? void 0 : props[key];
|
|
2854
|
+
if (typeof value === "number" && isFinite(value)) out[key] = value;
|
|
2855
|
+
}
|
|
2856
|
+
return out;
|
|
2857
|
+
}
|
|
2858
|
+
function buildHostDecorationLayers() {
|
|
2859
|
+
return [
|
|
2860
|
+
{
|
|
2861
|
+
id: HOST_DECORATION_LAYER_IDS.arrowheads,
|
|
2862
|
+
type: "symbol",
|
|
2863
|
+
source: HOST_DECORATION_SOURCE_ID,
|
|
2864
|
+
filter: ["==", ["get", "role"], "arrow"],
|
|
2865
|
+
layout: {
|
|
2866
|
+
"icon-image": ARROWHEAD_IMAGE_ID,
|
|
2867
|
+
"icon-size": ["coalesce", ["get", "arrowScale"], 1],
|
|
2868
|
+
"icon-rotate": ["coalesce", ["get", "arrowBearing"], 0],
|
|
2869
|
+
"icon-rotation-alignment": "map",
|
|
2870
|
+
"icon-pitch-alignment": "map",
|
|
2871
|
+
// The image points up; with `icon-rotate` the offset is in the rotated
|
|
2872
|
+
// frame, so +y pulls the head back along the line.
|
|
2873
|
+
"icon-offset": zoomCurve(offsetAlongYAt),
|
|
2874
|
+
"icon-allow-overlap": true,
|
|
2875
|
+
"icon-ignore-placement": true
|
|
2876
|
+
},
|
|
2877
|
+
paint: {
|
|
2878
|
+
"icon-color": ["coalesce", ["get", "stroke"], "#3b82f6"],
|
|
2879
|
+
"icon-opacity": ["coalesce", ["get", "stroke-opacity"], 1]
|
|
2880
|
+
}
|
|
2881
|
+
},
|
|
2882
|
+
{
|
|
2883
|
+
id: HOST_DECORATION_LAYER_IDS.labels,
|
|
2884
|
+
type: "symbol",
|
|
2885
|
+
source: HOST_DECORATION_SOURCE_ID,
|
|
2886
|
+
filter: ["==", ["get", "role"], "label"],
|
|
2887
|
+
layout: {
|
|
2888
|
+
"text-field": ["get", "name"],
|
|
2889
|
+
"text-size": ["coalesce", ["get", "fontSize"], 12],
|
|
2890
|
+
"text-font": ["literal", ["Montserrat Regular", "Noto Sans Regular"]],
|
|
2891
|
+
"text-rotate": ["coalesce", ["get", "labelRotate"], 0],
|
|
2892
|
+
"text-rotation-alignment": "map",
|
|
2893
|
+
"text-anchor": "center",
|
|
2894
|
+
"text-padding": 2,
|
|
2895
|
+
"text-allow-overlap": false,
|
|
2896
|
+
"text-ignore-placement": false
|
|
2897
|
+
},
|
|
2898
|
+
paint: {
|
|
2899
|
+
"text-color": ["coalesce", ["get", "fontColor"], "#1f2937"],
|
|
2900
|
+
"text-halo-color": "#ffffff",
|
|
2901
|
+
// Wide enough to close the gaps between words, where the line under
|
|
2902
|
+
// the label would otherwise show through.
|
|
2903
|
+
"text-halo-width": 2.5,
|
|
2904
|
+
"text-opacity": ["coalesce", ["get", "stroke-opacity"], 1]
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
];
|
|
2908
|
+
}
|
|
2909
|
+
function buildArrowheadImage(pixelRatio) {
|
|
2910
|
+
const ratio = pixelRatio > 0 && isFinite(pixelRatio) ? pixelRatio : 1;
|
|
2911
|
+
const cssW = ARROWHEAD_WIDTH + 2 * ARROWHEAD_BUFFER;
|
|
2912
|
+
const cssH = ARROWHEAD_LENGTH + 2 * ARROWHEAD_BUFFER;
|
|
2913
|
+
const width = Math.round(cssW * ratio);
|
|
2914
|
+
const height = Math.round(cssH * ratio);
|
|
2915
|
+
const tip = [cssW / 2, ARROWHEAD_BUFFER];
|
|
2916
|
+
const left = [ARROWHEAD_BUFFER, ARROWHEAD_BUFFER + ARROWHEAD_LENGTH];
|
|
2917
|
+
const right = [ARROWHEAD_BUFFER + ARROWHEAD_WIDTH, ARROWHEAD_BUFFER + ARROWHEAD_LENGTH];
|
|
2918
|
+
const edges = [[tip, right], [right, left], [left, tip]];
|
|
2919
|
+
const data = new Uint8Array(width * height * 4);
|
|
2920
|
+
for (let j = 0; j < height; j++) {
|
|
2921
|
+
for (let i = 0; i < width; i++) {
|
|
2922
|
+
const px = (i + 0.5) / ratio;
|
|
2923
|
+
const py = (j + 0.5) / ratio;
|
|
2924
|
+
let inside = Infinity;
|
|
2925
|
+
for (const [a, b] of edges) {
|
|
2926
|
+
const ex = b[0] - a[0];
|
|
2927
|
+
const ey = b[1] - a[1];
|
|
2928
|
+
const d = ((py - a[1]) * ex - (px - a[0]) * ey) / Math.hypot(ex, ey);
|
|
2929
|
+
if (d < inside) inside = d;
|
|
2930
|
+
}
|
|
2931
|
+
const alpha = Math.max(0, Math.min(1, 0.75 + inside * (0.75 / ARROWHEAD_BUFFER)));
|
|
2932
|
+
const o = (j * width + i) * 4;
|
|
2933
|
+
data[o] = 255;
|
|
2934
|
+
data[o + 1] = 255;
|
|
2935
|
+
data[o + 2] = 255;
|
|
2936
|
+
data[o + 3] = Math.round(alpha * 255);
|
|
2937
|
+
}
|
|
2938
|
+
}
|
|
2939
|
+
return { width, height, data };
|
|
2940
|
+
}
|
|
2435
2941
|
function placeContextMenu(point2, parent, menu) {
|
|
2436
2942
|
const scaleX = parent.offsetWidth > 0 ? parent.rect.width / parent.offsetWidth : 1;
|
|
2437
2943
|
const scaleY = parent.offsetHeight > 0 ? parent.rect.height / parent.offsetHeight : 1;
|
|
@@ -4634,7 +5140,8 @@ function LayersPanel({
|
|
|
4634
5140
|
onClick: () => onFitToLayerFeatures(layer.id)
|
|
4635
5141
|
}
|
|
4636
5142
|
] : [],
|
|
4637
|
-
|
|
5143
|
+
// A host-owned layer is removed by its host, never from here.
|
|
5144
|
+
...layers.length > 1 && !layer.hostOwned ? [
|
|
4638
5145
|
{ type: "divider" },
|
|
4639
5146
|
{
|
|
4640
5147
|
key: "delete",
|
|
@@ -5694,6 +6201,7 @@ function resolveTooltipFeature(rendered, lookup) {
|
|
|
5694
6201
|
};
|
|
5695
6202
|
}
|
|
5696
6203
|
const DEFAULT_POINT_RADIUS = 5;
|
|
6204
|
+
const DEFAULT_ICON_SIZE = 24;
|
|
5697
6205
|
const MAX_POINT_RADIUS = 18;
|
|
5698
6206
|
const SAME_SPOT_PX = 1;
|
|
5699
6207
|
const CROWD = 16;
|
|
@@ -5703,8 +6211,12 @@ const distance = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
|
|
|
5703
6211
|
function paintedRadius(f) {
|
|
5704
6212
|
var _a, _b;
|
|
5705
6213
|
const p = f.properties ?? {};
|
|
5706
|
-
const hidden = ((_a = f.state) == null ? void 0 : _a[TIMELINE_HIDDEN_KEY]) === true || p.isHiddenByCluster === 1 || p.isHiddenByHeatmap === 1
|
|
6214
|
+
const hidden = ((_a = f.state) == null ? void 0 : _a[TIMELINE_HIDDEN_KEY]) === true || p.isHiddenByCluster === 1 || p.isHiddenByHeatmap === 1;
|
|
5707
6215
|
if (hidden) return 0;
|
|
6216
|
+
if (typeof p.icon === "string" && p.icon !== "") {
|
|
6217
|
+
if (p[HOST_OWNED_PROP] !== 1) return 0;
|
|
6218
|
+
return typeof p.iconSize === "number" && Number.isFinite(p.iconSize) ? p.iconSize / 2 : DEFAULT_ICON_SIZE / 2;
|
|
6219
|
+
}
|
|
5708
6220
|
const r = ((_b = f.state) == null ? void 0 : _b[TRACE_ENDPOINT_KEY]) === true ? p._endpointRadius : p.pointRadius;
|
|
5709
6221
|
return typeof r === "number" && Number.isFinite(r) ? r : DEFAULT_POINT_RADIUS;
|
|
5710
6222
|
}
|
|
@@ -6189,7 +6701,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
6189
6701
|
setStrokeColor(feature.properties.stroke || "#3b82f6");
|
|
6190
6702
|
setStrokeWidth(feature.properties["stroke-width"] || 2);
|
|
6191
6703
|
setStrokeOpacity(feature.properties["stroke-opacity"] ?? 1);
|
|
6192
|
-
setFillColor(feature.properties.
|
|
6704
|
+
setFillColor(ownFill(feature.properties) ?? (feature.properties.stroke || "#3b82f6"));
|
|
6193
6705
|
setFillOpacity(feature.properties["fill-opacity"] ?? 0.2);
|
|
6194
6706
|
setFontSize(feature.properties.fontSize || 14);
|
|
6195
6707
|
setFontColor(feature.properties.fontColor || "#000000");
|
|
@@ -6247,7 +6759,8 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
6247
6759
|
"longitude",
|
|
6248
6760
|
// The marker color is shown via the colored dot in the panel header,
|
|
6249
6761
|
// so we don't repeat it as an editable property row.
|
|
6250
|
-
"color"
|
|
6762
|
+
"color",
|
|
6763
|
+
FILL_PICKED_PROP
|
|
6251
6764
|
]);
|
|
6252
6765
|
const isReservedKey = buildKeyExclusionPredicate(reserved);
|
|
6253
6766
|
const custom = [];
|
|
@@ -6298,9 +6811,15 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
6298
6811
|
"stroke": (overrides == null ? void 0 : overrides.strokeColor) ?? strokeColor,
|
|
6299
6812
|
"stroke-width": (overrides == null ? void 0 : overrides.strokeWidth) ?? strokeWidth,
|
|
6300
6813
|
"stroke-opacity": (overrides == null ? void 0 : overrides.strokeOpacity) ?? strokeOpacity,
|
|
6301
|
-
"fill": (overrides == null ? void 0 : overrides.fillColor) ?? fillColor,
|
|
6302
6814
|
"fill-opacity": (overrides == null ? void 0 : overrides.fillOpacity) ?? fillOpacity
|
|
6303
6815
|
};
|
|
6816
|
+
if ((overrides == null ? void 0 : overrides.fillColor) === null) {
|
|
6817
|
+
properties.fill = void 0;
|
|
6818
|
+
properties[FILL_PICKED_PROP] = void 0;
|
|
6819
|
+
} else if ((overrides == null ? void 0 : overrides.fillColor) !== void 0) {
|
|
6820
|
+
properties.fill = overrides.fillColor;
|
|
6821
|
+
properties[FILL_PICKED_PROP] = true;
|
|
6822
|
+
}
|
|
6304
6823
|
if ((overrides == null ? void 0 : overrides.entityType) !== void 0) {
|
|
6305
6824
|
properties.entityType = overrides.entityType;
|
|
6306
6825
|
} else if (entityType !== void 0) {
|
|
@@ -6337,7 +6856,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
6337
6856
|
}
|
|
6338
6857
|
});
|
|
6339
6858
|
onUpdateProperties(feature.id, properties);
|
|
6340
|
-
}, [feature, name, description, startDate, endDate, strokeColor, strokeWidth, strokeOpacity,
|
|
6859
|
+
}, [feature, name, description, startDate, endDate, strokeColor, strokeWidth, strokeOpacity, fillOpacity, fontSize, fontColor, fontWeight, arrowSize, pointIcon, pointIconSize, entityType, customProperties, onUpdateProperties, isEditMode]);
|
|
6341
6860
|
const handleAddProperty = useCallback(() => {
|
|
6342
6861
|
if (!newPropertyKey.trim() || !isEditMode) return;
|
|
6343
6862
|
setCustomProperties((prev) => [...prev, { key: newPropertyKey.trim(), value: "" }]);
|
|
@@ -6804,6 +7323,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
6804
7323
|
onChange: (color) => {
|
|
6805
7324
|
const hex = color.toHexString();
|
|
6806
7325
|
setStrokeColor(hex);
|
|
7326
|
+
if (!ownFill(feature.properties)) setFillColor(hex);
|
|
6807
7327
|
handleSave({ strokeColor: hex });
|
|
6808
7328
|
},
|
|
6809
7329
|
disabled: !isEditMode,
|
|
@@ -6890,6 +7410,20 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
6890
7410
|
"data-testid": "color-picker-fill"
|
|
6891
7411
|
}
|
|
6892
7412
|
) }) }),
|
|
7413
|
+
isEditMode && ownFill(feature.properties) && /* @__PURE__ */ jsx(Tooltip, { title: "Reset fill to the stroke colour", children: /* @__PURE__ */ jsx(
|
|
7414
|
+
Button,
|
|
7415
|
+
{
|
|
7416
|
+
size: "small",
|
|
7417
|
+
type: "text",
|
|
7418
|
+
icon: /* @__PURE__ */ jsx(RotateCcw, { className: "w-3 h-3" }),
|
|
7419
|
+
"aria-label": "Reset fill to the stroke colour",
|
|
7420
|
+
onClick: () => {
|
|
7421
|
+
setFillColor(strokeColor);
|
|
7422
|
+
handleSave({ fillColor: null });
|
|
7423
|
+
},
|
|
7424
|
+
"data-testid": "button-reset-fill"
|
|
7425
|
+
}
|
|
7426
|
+
) }),
|
|
6893
7427
|
/* @__PURE__ */ jsx(Tooltip, { title: "Fill Opacity", children: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", children: [
|
|
6894
7428
|
/* @__PURE__ */ jsx(Blend, { className: "w-3 h-3 text-muted-foreground" }),
|
|
6895
7429
|
/* @__PURE__ */ jsx(
|
|
@@ -9137,6 +9671,7 @@ function hitTestSelection(featureGroups, selectionPolygon, options) {
|
|
|
9137
9671
|
const SELECTION_OVERLAY_SOURCE_ID = "selection-overlay";
|
|
9138
9672
|
const SELECTION_OVERLAY_LAYER_IDS = {
|
|
9139
9673
|
iconRing: "selection-overlay-icon-ring",
|
|
9674
|
+
hostIconRing: "selection-overlay-host-icon-ring",
|
|
9140
9675
|
line: "selection-overlay-line",
|
|
9141
9676
|
polygon: "selection-overlay-polygon",
|
|
9142
9677
|
label: "selection-overlay-label"
|
|
@@ -9148,7 +9683,7 @@ function buildSelectionOverlayStack() {
|
|
|
9148
9683
|
id: SELECTION_OVERLAY_LAYER_IDS.iconRing,
|
|
9149
9684
|
type: "circle",
|
|
9150
9685
|
source,
|
|
9151
|
-
filter: ["all", ["==", "$type", "Point"], ["!=", "icon", ""], ["!=", "isHiddenByHeatmap", 1]],
|
|
9686
|
+
filter: ["all", ["==", "$type", "Point"], ["!=", "icon", ""], ["!=", "isHiddenByHeatmap", 1], ["!=", HOST_OWNED_PROP, 1]],
|
|
9152
9687
|
paint: {
|
|
9153
9688
|
"circle-color": "transparent",
|
|
9154
9689
|
"circle-radius": ["/", ["coalesce", ["get", "iconSize"], 24], 1.6],
|
|
@@ -9157,6 +9692,20 @@ function buildSelectionOverlayStack() {
|
|
|
9157
9692
|
"circle-stroke-opacity": 1
|
|
9158
9693
|
}
|
|
9159
9694
|
},
|
|
9695
|
+
{
|
|
9696
|
+
// A host icon shrinks along the host's zoom curve, and its ring with it.
|
|
9697
|
+
id: SELECTION_OVERLAY_LAYER_IDS.hostIconRing,
|
|
9698
|
+
type: "circle",
|
|
9699
|
+
source,
|
|
9700
|
+
filter: ["all", ["==", "$type", "Point"], ["!=", "icon", ""], ["==", HOST_OWNED_PROP, 1]],
|
|
9701
|
+
paint: {
|
|
9702
|
+
"circle-color": "transparent",
|
|
9703
|
+
"circle-radius": zoomCurve((z) => ["/", ["*", ["coalesce", ["get", "iconSize"], 24], hostIconScaleAt(z)], 1.6]),
|
|
9704
|
+
"circle-stroke-color": SELECTION_COLOR,
|
|
9705
|
+
"circle-stroke-width": 3,
|
|
9706
|
+
"circle-stroke-opacity": 1
|
|
9707
|
+
}
|
|
9708
|
+
},
|
|
9160
9709
|
{
|
|
9161
9710
|
id: SELECTION_OVERLAY_LAYER_IDS.line,
|
|
9162
9711
|
type: "line",
|
|
@@ -9183,6 +9732,8 @@ function buildSelectionOverlayStack() {
|
|
|
9183
9732
|
id: SELECTION_OVERLAY_LAYER_IDS.label,
|
|
9184
9733
|
type: "symbol",
|
|
9185
9734
|
source,
|
|
9735
|
+
// A selected host feature keeps its label in the shared `host-labels` layer.
|
|
9736
|
+
filter: NOT_HOST_FILTER,
|
|
9186
9737
|
layout: {
|
|
9187
9738
|
...buildCustomLabelLayout(),
|
|
9188
9739
|
// Never hidden by the auto-label density cap, which only flips the
|
|
@@ -9208,105 +9759,6 @@ function buildSelectionOverlayData(ids, styleFor) {
|
|
|
9208
9759
|
});
|
|
9209
9760
|
return { type: "FeatureCollection", features };
|
|
9210
9761
|
}
|
|
9211
|
-
const CLUSTER_COUNT_VALUE_PROP = "__cluster_count_value";
|
|
9212
|
-
const CLUSTER_SUM_PROP = "value_sum";
|
|
9213
|
-
const CLUSTER_MEMBER_ID_PROP = "__cluster_fid";
|
|
9214
|
-
function clusterCountValue(raw) {
|
|
9215
|
-
if (typeof raw === "number") return Number.isFinite(raw) ? raw : 1;
|
|
9216
|
-
if (typeof raw === "string" && raw.trim() !== "") {
|
|
9217
|
-
const n = Number(raw);
|
|
9218
|
-
if (Number.isFinite(n)) return n;
|
|
9219
|
-
}
|
|
9220
|
-
return 1;
|
|
9221
|
-
}
|
|
9222
|
-
function injectClusterCountValues(features, fieldName) {
|
|
9223
|
-
return features.map((f) => {
|
|
9224
|
-
var _a;
|
|
9225
|
-
return {
|
|
9226
|
-
...f,
|
|
9227
|
-
properties: {
|
|
9228
|
-
...f.properties,
|
|
9229
|
-
[CLUSTER_COUNT_VALUE_PROP]: clusterCountValue((_a = f.properties) == null ? void 0 : _a[fieldName]),
|
|
9230
|
-
...f.id != null ? { [CLUSTER_MEMBER_ID_PROP]: String(f.id) } : {}
|
|
9231
|
-
}
|
|
9232
|
-
};
|
|
9233
|
-
});
|
|
9234
|
-
}
|
|
9235
|
-
function roundHalfAwayFromZero1(n) {
|
|
9236
|
-
return Math.sign(n) * Math.round(Math.abs(n) * 10) / 10;
|
|
9237
|
-
}
|
|
9238
|
-
function formatClusterBadge(value) {
|
|
9239
|
-
if (value >= 1e6) return `${roundHalfAwayFromZero1(value / 1e6)}M`;
|
|
9240
|
-
if (value >= 1e3) return `${roundHalfAwayFromZero1(value / 1e3)}k`;
|
|
9241
|
-
return String(roundHalfAwayFromZero1(value));
|
|
9242
|
-
}
|
|
9243
|
-
function clusterBadgeTextField(prop) {
|
|
9244
|
-
const value = ["get", prop];
|
|
9245
|
-
const round1 = (expr) => ["/", ["round", ["*", expr, 10]], 10];
|
|
9246
|
-
return [
|
|
9247
|
-
"step",
|
|
9248
|
-
value,
|
|
9249
|
-
["to-string", round1(value)],
|
|
9250
|
-
1e3,
|
|
9251
|
-
["concat", ["to-string", round1(["/", value, 1e3])], "k"],
|
|
9252
|
-
1e6,
|
|
9253
|
-
["concat", ["to-string", round1(["/", value, 1e6])], "M"]
|
|
9254
|
-
];
|
|
9255
|
-
}
|
|
9256
|
-
const INTERNAL_PROPERTY_KEYS = /* @__PURE__ */ new Set([
|
|
9257
|
-
"fill",
|
|
9258
|
-
"fill-opacity",
|
|
9259
|
-
"pointRadius",
|
|
9260
|
-
"pointIcon",
|
|
9261
|
-
"pointIconSize",
|
|
9262
|
-
"circleCenter",
|
|
9263
|
-
"circleRadius",
|
|
9264
|
-
"icon",
|
|
9265
|
-
"iconSize",
|
|
9266
|
-
"fontSize",
|
|
9267
|
-
"fontColor",
|
|
9268
|
-
"fontWeight",
|
|
9269
|
-
"arrowSize",
|
|
9270
|
-
"label",
|
|
9271
|
-
"entityType",
|
|
9272
|
-
"kind",
|
|
9273
|
-
"meta:type",
|
|
9274
|
-
"stroke",
|
|
9275
|
-
"stroke-width",
|
|
9276
|
-
"stroke-opacity",
|
|
9277
|
-
CLUSTER_COUNT_VALUE_PROP,
|
|
9278
|
-
CLUSTER_MEMBER_ID_PROP
|
|
9279
|
-
]);
|
|
9280
|
-
const STYLING_PROPERTY_KEYS = [
|
|
9281
|
-
"stroke",
|
|
9282
|
-
"stroke-width",
|
|
9283
|
-
"stroke-opacity",
|
|
9284
|
-
"fill",
|
|
9285
|
-
"fill-opacity",
|
|
9286
|
-
"pointRadius",
|
|
9287
|
-
"pointIcon",
|
|
9288
|
-
"pointIconSize",
|
|
9289
|
-
"icon",
|
|
9290
|
-
"iconSize",
|
|
9291
|
-
"circleCenter",
|
|
9292
|
-
"circleRadius",
|
|
9293
|
-
"fontSize",
|
|
9294
|
-
"fontColor",
|
|
9295
|
-
"fontWeight",
|
|
9296
|
-
"arrowSize"
|
|
9297
|
-
];
|
|
9298
|
-
const INTERNAL_PROPERTY_PREFIXES = [
|
|
9299
|
-
"IsHiddenBy",
|
|
9300
|
-
"isHidden",
|
|
9301
|
-
"isSelected",
|
|
9302
|
-
"isTrace",
|
|
9303
|
-
"isTimeline",
|
|
9304
|
-
"trace"
|
|
9305
|
-
];
|
|
9306
|
-
function isInternalProperty(key) {
|
|
9307
|
-
if (INTERNAL_PROPERTY_KEYS.has(key)) return true;
|
|
9308
|
-
return INTERNAL_PROPERTY_PREFIXES.some((prefix) => key.startsWith(prefix));
|
|
9309
|
-
}
|
|
9310
9762
|
function computeBubbleDomain(values) {
|
|
9311
9763
|
let min = Infinity;
|
|
9312
9764
|
let max = -Infinity;
|
|
@@ -9713,7 +10165,6 @@ function ClusterPieManager(props) {
|
|
|
9713
10165
|
}
|
|
9714
10166
|
const EMPTY_ID_SET = /* @__PURE__ */ new Set();
|
|
9715
10167
|
const EMPTY_SOURCES = [];
|
|
9716
|
-
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"];
|
|
9717
10168
|
const EMPTY_LABEL_MAP = /* @__PURE__ */ new Map();
|
|
9718
10169
|
const TICK_COUNT_SETTLE_MS = 300;
|
|
9719
10170
|
const SPATIAL_COUNT_MIN_FEATURES = 5e3;
|
|
@@ -9735,7 +10186,7 @@ function emojiCanvasToImageData(canvas) {
|
|
|
9735
10186
|
const id = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
9736
10187
|
return { width: canvas.width, height: canvas.height, data: new Uint8Array(id.data.buffer) };
|
|
9737
10188
|
}
|
|
9738
|
-
function loadEmojiIconsIntoMap(mapInstance) {
|
|
10189
|
+
function loadEmojiIconsIntoMap(mapInstance, hostImages) {
|
|
9739
10190
|
const ratio = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
9740
10191
|
for (const { emoji } of ICONS) {
|
|
9741
10192
|
if (!emoji || mapInstance.hasImage(emoji)) continue;
|
|
@@ -9746,10 +10197,19 @@ function loadEmojiIconsIntoMap(mapInstance) {
|
|
|
9746
10197
|
}
|
|
9747
10198
|
}
|
|
9748
10199
|
mapInstance.setMissingStyleImageResolver((id) => {
|
|
9749
|
-
if (mapInstance.hasImage(id)
|
|
10200
|
+
if (mapInstance.hasImage(id)) return;
|
|
9750
10201
|
try {
|
|
9751
|
-
|
|
9752
|
-
|
|
10202
|
+
if (id === ARROWHEAD_IMAGE_ID) {
|
|
10203
|
+
mapInstance.addImage(id, buildArrowheadImage(ratio), { pixelRatio: ratio, sdf: true });
|
|
10204
|
+
return;
|
|
10205
|
+
}
|
|
10206
|
+
const resolved = resolveMissingImage(id, hostImages());
|
|
10207
|
+
if (resolved.kind === "host") {
|
|
10208
|
+
mapInstance.addImage(id, resolved.image.data, { pixelRatio: resolved.image.pixelRatio ?? 1 });
|
|
10209
|
+
} else if (resolved.kind === "emoji" && isEmojiIcon(id)) {
|
|
10210
|
+
const canvas = renderEmojiToCanvas(id);
|
|
10211
|
+
mapInstance.addImage(id, emojiCanvasToImageData(canvas), { pixelRatio: ratio });
|
|
10212
|
+
}
|
|
9753
10213
|
} catch {
|
|
9754
10214
|
}
|
|
9755
10215
|
});
|
|
@@ -9963,6 +10423,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9963
10423
|
onFeatureCreate,
|
|
9964
10424
|
onFeatureUpdate,
|
|
9965
10425
|
onFeatureDelete,
|
|
10426
|
+
onDeleteRequest,
|
|
10427
|
+
iconImageProvider,
|
|
9966
10428
|
onLayerChange,
|
|
9967
10429
|
onActiveEditingLayerChange,
|
|
9968
10430
|
onTimelineChange,
|
|
@@ -10062,6 +10524,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10062
10524
|
const moveLabelsBeforeBasemapSymbolsRef = useRef(null);
|
|
10063
10525
|
const tooltipProviderRef = useRef(tooltipProvider);
|
|
10064
10526
|
tooltipProviderRef.current = tooltipProvider;
|
|
10527
|
+
const onFeatureSelectRef = useRef(onFeatureSelect);
|
|
10528
|
+
onFeatureSelectRef.current = onFeatureSelect;
|
|
10529
|
+
const onDeleteRequestRef = useRef(onDeleteRequest);
|
|
10530
|
+
onDeleteRequestRef.current = onDeleteRequest;
|
|
10531
|
+
const iconImageProviderRef = useRef(iconImageProvider);
|
|
10532
|
+
iconImageProviderRef.current = iconImageProvider;
|
|
10065
10533
|
const onFeatureUpdateRef = useRef(onFeatureUpdate);
|
|
10066
10534
|
onFeatureUpdateRef.current = onFeatureUpdate;
|
|
10067
10535
|
const restoreEnrichedGeoJSONRef = useRef(null);
|
|
@@ -10102,6 +10570,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10102
10570
|
const pendingFeatureKindRef = useRef(null);
|
|
10103
10571
|
const arrowFeatureIdsRef = useRef(/* @__PURE__ */ new Set());
|
|
10104
10572
|
const hasArrowFeaturesRef = useRef(false);
|
|
10573
|
+
const hadHostDecorationsRef = useRef(false);
|
|
10105
10574
|
const [circleDrawCenter, setCircleDrawCenter] = useState(null);
|
|
10106
10575
|
const [circleDrawPreview, setCircleDrawPreview] = useState(null);
|
|
10107
10576
|
const isDrawingCircle = useRef(false);
|
|
@@ -10122,6 +10591,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10122
10591
|
const ingestProgressStoreRef = useRef(null);
|
|
10123
10592
|
const bindHoverHandlersRef = useRef(null);
|
|
10124
10593
|
const unbindHoverHandlersRef = useRef(null);
|
|
10594
|
+
const hostIconBoundRef = useRef(false);
|
|
10125
10595
|
const [labelsSuppressed, setLabelsSuppressed] = useState(true);
|
|
10126
10596
|
const labelsSuppressedRef = useRef(labelsSuppressed);
|
|
10127
10597
|
labelsSuppressedRef.current = labelsSuppressed;
|
|
@@ -10352,7 +10822,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10352
10822
|
const applySelectionState$1 = useCallback((nextIds, options) => {
|
|
10353
10823
|
if (!isMapLoaded || !draw.current) {
|
|
10354
10824
|
setSelectedFeatureIds(nextIds);
|
|
10355
|
-
if (options == null ? void 0 : options.focusProperties) setShowProperties(nextIds.
|
|
10825
|
+
if (options == null ? void 0 : options.focusProperties) setShowProperties(showsPropertiesFor(nextIds, layersRef.current));
|
|
10356
10826
|
if (onFeatureSelect) {
|
|
10357
10827
|
onFeatureSelect(nextIds.length > 0 ? nextIds.map((id) => getFeatureById(id)).filter(Boolean) : []);
|
|
10358
10828
|
}
|
|
@@ -10389,7 +10859,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10389
10859
|
}
|
|
10390
10860
|
setSelectedFeatureIds(nextIds);
|
|
10391
10861
|
selectedFeatureIdsRef.current = nextIds;
|
|
10392
|
-
if (options == null ? void 0 : options.focusProperties) setShowProperties(nextIds.
|
|
10862
|
+
if (options == null ? void 0 : options.focusProperties) setShowProperties(showsPropertiesFor(nextIds, layersRef.current));
|
|
10393
10863
|
if (onFeatureSelect) {
|
|
10394
10864
|
onFeatureSelect(nextIds.map((id) => getFeatureById(id)).filter(Boolean));
|
|
10395
10865
|
}
|
|
@@ -10557,7 +11027,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10557
11027
|
}
|
|
10558
11028
|
readOnlyFeatures.current.forEach((features, layerId) => {
|
|
10559
11029
|
const layer = layersRef.current.find((l) => l.id === layerId);
|
|
10560
|
-
if (layer == null ? void 0 : layer.visible)
|
|
11030
|
+
if (!(layer == null ? void 0 : layer.visible)) return;
|
|
11031
|
+
groups.push(isHostOwnedLayer(layer) ? { features } : groupOf(features));
|
|
10561
11032
|
});
|
|
10562
11033
|
return countFeaturesInBounds(
|
|
10563
11034
|
groups,
|
|
@@ -10569,7 +11040,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10569
11040
|
const tracePaintCacheRef = useRef(null);
|
|
10570
11041
|
const traceEndpointsRef = useRef(/* @__PURE__ */ new Set());
|
|
10571
11042
|
const paintedArrowLinesRef = useRef([]);
|
|
10572
|
-
const renderArrowOverlays = useCallback((arrowLines) => {
|
|
11043
|
+
const renderArrowOverlays = useCallback((arrowLines, options) => {
|
|
10573
11044
|
const mapInstance = map.current;
|
|
10574
11045
|
if (!mapInstance) return;
|
|
10575
11046
|
const arrowHeadSource = mapInstance.getSource("arrow-heads");
|
|
@@ -10624,7 +11095,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10624
11095
|
arrowHeadSource.setData({ type: "FeatureCollection", features: arrowHeadTriangles });
|
|
10625
11096
|
}
|
|
10626
11097
|
const arrowLabelSource = mapInstance.getSource("arrow-labels");
|
|
10627
|
-
if (arrowLabelSource) {
|
|
11098
|
+
if (arrowLabelSource && !(options == null ? void 0 : options.headsOnly)) {
|
|
10628
11099
|
const arrowLabelPoints = [];
|
|
10629
11100
|
arrowLines.forEach((f) => {
|
|
10630
11101
|
var _a;
|
|
@@ -10697,7 +11168,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10697
11168
|
const layer = currentLayers.find((l) => l.id === layerId);
|
|
10698
11169
|
if (layer && isLayerVisible(layer)) {
|
|
10699
11170
|
pushAll(allFeatures, features);
|
|
10700
|
-
addSlice(features);
|
|
11171
|
+
if (!isHostOwnedLayer(layer)) addSlice(features);
|
|
10701
11172
|
}
|
|
10702
11173
|
});
|
|
10703
11174
|
const featureById = /* @__PURE__ */ new Map();
|
|
@@ -10802,9 +11273,14 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10802
11273
|
const { s, e } = record ? featureInterval(record, timelineFieldsNow) : { s: NaN, e: NaN };
|
|
10803
11274
|
arrowLines.push(isIntervalVisible(s, e, timelineWindow) ? styled : { ...styled, properties: { ...styled.properties, "stroke-opacity": 0, "fill-opacity": 0 } });
|
|
10804
11275
|
};
|
|
11276
|
+
const hostLines = [];
|
|
10805
11277
|
sourceData.features.forEach((f, i) => {
|
|
10806
|
-
var _a2;
|
|
10807
|
-
|
|
11278
|
+
var _a2, _b2;
|
|
11279
|
+
if (((_a2 = f.properties) == null ? void 0 : _a2[HOST_OWNED_PROP]) === 1) {
|
|
11280
|
+
if (f.geometry.type === "LineString") hostLines.push({ styled: f, record: allFeatures[i] });
|
|
11281
|
+
return;
|
|
11282
|
+
}
|
|
11283
|
+
const isArrow = ((_b2 = f.properties) == null ? void 0 : _b2.kind) === "arrow" || arrowFeatureIdsRef.current.has(String(f.id));
|
|
10808
11284
|
if (!isArrow) return;
|
|
10809
11285
|
sawArrowFeature = true;
|
|
10810
11286
|
if (f.geometry.type === "LineString") pushArrow(f, allFeatures[i]);
|
|
@@ -10820,6 +11296,11 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10820
11296
|
hasArrowFeaturesRef.current = sawArrowFeature;
|
|
10821
11297
|
paintedArrowLinesRef.current = arrowLines;
|
|
10822
11298
|
renderArrowOverlays(arrowLines);
|
|
11299
|
+
const hostDecorationSource = map.current.getSource(HOST_DECORATION_SOURCE_ID);
|
|
11300
|
+
if (hostDecorationSource && (hostLines.length > 0 || hadHostDecorationsRef.current)) {
|
|
11301
|
+
hostDecorationSource.setData({ type: "FeatureCollection", features: buildHostLineDecorations(hostLines) });
|
|
11302
|
+
hadHostDecorationsRef.current = hostLines.length > 0;
|
|
11303
|
+
}
|
|
10823
11304
|
}
|
|
10824
11305
|
if (update3DFlightPathsRef == null ? void 0 : update3DFlightPathsRef.current) {
|
|
10825
11306
|
update3DFlightPathsRef.current();
|
|
@@ -11059,7 +11540,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11059
11540
|
);
|
|
11060
11541
|
readOnlyFeatures.current.forEach((features, layerId) => {
|
|
11061
11542
|
const layer = currentLayers.find((l) => l.id === layerId);
|
|
11062
|
-
if (!(layer == null ? void 0 : layer.visible)) return;
|
|
11543
|
+
if (!(layer == null ? void 0 : layer.visible) || isHostOwnedLayer(layer)) return;
|
|
11063
11544
|
const cached = layerTemporalCacheRef.current.get(layerId);
|
|
11064
11545
|
if (cached && (cached.fieldsKey ?? "") === fieldsKey && cached.featureCount === features.length && !cached.hasTemporal) {
|
|
11065
11546
|
for (const f of features) scan.untimedIds.push(f.id);
|
|
@@ -11107,10 +11588,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11107
11588
|
}, [updateTimelineStore]);
|
|
11108
11589
|
const collectHistoryFeatures = useCallback(
|
|
11109
11590
|
(overrides) => {
|
|
11110
|
-
var _a;
|
|
11111
11591
|
const featureToLayer = /* @__PURE__ */ new Map();
|
|
11112
11592
|
for (const l of layersRef.current) {
|
|
11113
|
-
if ((
|
|
11593
|
+
if (isHistoryExcludedLayer(l)) continue;
|
|
11114
11594
|
for (const fid of l.featureIds) featureToLayer.set(fid, l.id);
|
|
11115
11595
|
}
|
|
11116
11596
|
const result = /* @__PURE__ */ new Map();
|
|
@@ -11126,9 +11606,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11126
11606
|
}
|
|
11127
11607
|
}
|
|
11128
11608
|
readOnlyFeatures.current.forEach((features, layerId) => {
|
|
11129
|
-
var _a2;
|
|
11130
11609
|
const layer = layersRef.current.find((l) => l.id === layerId);
|
|
11131
|
-
if ((
|
|
11610
|
+
if (isHistoryExcludedLayer(layer)) return;
|
|
11132
11611
|
for (const f of features) {
|
|
11133
11612
|
if (f.id == null) continue;
|
|
11134
11613
|
result.set(String(f.id), { feature: f, layerId, store: "readOnly" });
|
|
@@ -11157,10 +11636,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11157
11636
|
[]
|
|
11158
11637
|
);
|
|
11159
11638
|
const collectHistoryLayers = useCallback(() => {
|
|
11160
|
-
var _a;
|
|
11161
11639
|
const result = /* @__PURE__ */ new Map();
|
|
11162
11640
|
for (const l of layersRef.current) {
|
|
11163
|
-
if ((
|
|
11641
|
+
if (isHistoryExcludedLayer(l)) continue;
|
|
11164
11642
|
const { importing: _importing, ...record } = l;
|
|
11165
11643
|
result.set(l.id, { ...record, featureIds: [...l.featureIds] });
|
|
11166
11644
|
}
|
|
@@ -11247,6 +11725,15 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11247
11725
|
if (!isMapLoaded) return;
|
|
11248
11726
|
cleanupOrphanLayerSources(new Set(layers.map((l) => l.id)));
|
|
11249
11727
|
}, [layers, isMapLoaded, cleanupOrphanLayerSources]);
|
|
11728
|
+
useEffect(() => {
|
|
11729
|
+
if (!isMapLoaded) return;
|
|
11730
|
+
const wanted = layers.some(isHostOwnedLayer);
|
|
11731
|
+
if (wanted === hostIconBoundRef.current) return;
|
|
11732
|
+
const toggle = wanted ? bindHoverHandlersRef.current : unbindHoverHandlersRef.current;
|
|
11733
|
+
if (!toggle) return;
|
|
11734
|
+
toggle(customLayerId("host-icon", SHARED_SOURCE_ID));
|
|
11735
|
+
hostIconBoundRef.current = wanted;
|
|
11736
|
+
}, [layers, isMapLoaded]);
|
|
11250
11737
|
const applyHistoryState = useCallback(
|
|
11251
11738
|
(featureIds, layerIds, targetFeatures, targetLayers) => {
|
|
11252
11739
|
const wasApiAdding = isApiAddingRef.current;
|
|
@@ -11389,8 +11876,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11389
11876
|
pending.beforeSelectedIds,
|
|
11390
11877
|
[...selectedFeatureIdsRef.current]
|
|
11391
11878
|
);
|
|
11392
|
-
|
|
11393
|
-
|
|
11879
|
+
const step = withHostDeleteUndos(command, pending.label, pending.hostUndos ?? []);
|
|
11880
|
+
if (step) {
|
|
11881
|
+
history.push(step);
|
|
11394
11882
|
}
|
|
11395
11883
|
}, [collectHistoryFeatures, collectHistoryLayers, buildDiffCommand, history]);
|
|
11396
11884
|
const saveStateForUndo = useCallback(
|
|
@@ -11525,7 +12013,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11525
12013
|
var _a2;
|
|
11526
12014
|
return (_a2 = unbindHoverHandlersRef.current) == null ? void 0 : _a2.call(unbindHoverHandlersRef, id);
|
|
11527
12015
|
}),
|
|
11528
|
-
labelsVisible: () => lastLabelVisibility.current
|
|
12016
|
+
labelsVisible: () => lastLabelVisibility.current,
|
|
12017
|
+
hostIconInteractive: () => hostIconBoundRef.current
|
|
11529
12018
|
});
|
|
11530
12019
|
shardRegistryRef.current.registerShared(sharedStack.map((spec) => spec.id));
|
|
11531
12020
|
mapInstance.addSource("arrow-heads", {
|
|
@@ -11572,6 +12061,14 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11572
12061
|
"text-opacity": ["coalesce", ["get", "stroke-opacity"], 1]
|
|
11573
12062
|
}
|
|
11574
12063
|
});
|
|
12064
|
+
mapInstance.addSource(HOST_DECORATION_SOURCE_ID, {
|
|
12065
|
+
type: "geojson",
|
|
12066
|
+
data: { type: "FeatureCollection", features: [] },
|
|
12067
|
+
maxzoom: 22
|
|
12068
|
+
});
|
|
12069
|
+
const [hostArrowheads, hostLineLabels] = buildHostDecorationLayers();
|
|
12070
|
+
mapInstance.addLayer(hostArrowheads, "custom-point-shadow");
|
|
12071
|
+
mapInstance.addLayer(hostLineLabels);
|
|
11575
12072
|
mapInstance.addSource(TRACE_SOURCE_ID, {
|
|
11576
12073
|
type: "geojson",
|
|
11577
12074
|
data: { type: "FeatureCollection", features: [] },
|
|
@@ -11715,7 +12212,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11715
12212
|
const highlightFields = /* @__PURE__ */ new Set();
|
|
11716
12213
|
if (((_a2 = visualConfig == null ? void 0 : visualConfig.size) == null ? void 0 : _a2.mode) === "field" && visualConfig.size.fieldName) highlightFields.add(visualConfig.size.fieldName);
|
|
11717
12214
|
if (((_b2 = visualConfig == null ? void 0 : visualConfig.color) == null ? void 0 : _b2.mode) === "field" && visualConfig.color.fieldName) highlightFields.add(visualConfig.color.fieldName);
|
|
11718
|
-
const displayProps = Object.entries(props).filter(([key, value]) => !
|
|
12215
|
+
const displayProps = Object.entries(props).filter(([key, value]) => !isInternalProperty(key) && !key.startsWith("_") && value != null && value !== "").slice(0, 5);
|
|
11719
12216
|
const name = props.name;
|
|
11720
12217
|
let html = '<div class="text-sm space-y-0.5">';
|
|
11721
12218
|
if (name) html += `<div class="font-medium">${escapeHtml(name)}</div>`;
|
|
@@ -11978,7 +12475,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11978
12475
|
tracePopupRef.current.remove();
|
|
11979
12476
|
}
|
|
11980
12477
|
});
|
|
11981
|
-
loadEmojiIconsIntoMap(mapInstance);
|
|
12478
|
+
loadEmojiIconsIntoMap(mapInstance, () => iconImageProviderRef.current);
|
|
11982
12479
|
setIsMapLoaded(true);
|
|
11983
12480
|
isMapLoadedRef.current = true;
|
|
11984
12481
|
updateFeatureCount();
|
|
@@ -12321,6 +12818,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12321
12818
|
onFeatureDelete == null ? void 0 : onFeatureDelete(deletedIds);
|
|
12322
12819
|
});
|
|
12323
12820
|
onDrawEvent(mapInstance, "draw.selectionchange", (e) => {
|
|
12821
|
+
var _a;
|
|
12324
12822
|
if (isSelectingReadOnlyRef.current) {
|
|
12325
12823
|
return;
|
|
12326
12824
|
}
|
|
@@ -12351,13 +12849,13 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12351
12849
|
setShowProperties(ids.length > 0);
|
|
12352
12850
|
}
|
|
12353
12851
|
scheduleSync("selection");
|
|
12354
|
-
|
|
12852
|
+
(_a = onFeatureSelectRef.current) == null ? void 0 : _a.call(onFeatureSelectRef, e.features);
|
|
12355
12853
|
});
|
|
12356
12854
|
onDrawEvent(mapInstance, "draw.modechange", () => {
|
|
12357
12855
|
scheduleSync();
|
|
12358
12856
|
});
|
|
12359
12857
|
mapInstance.on("click", (e) => {
|
|
12360
|
-
var _a, _b;
|
|
12858
|
+
var _a, _b, _c;
|
|
12361
12859
|
if (!enableSelectionRef.current) return;
|
|
12362
12860
|
if (e.originalEvent.button !== 0) return;
|
|
12363
12861
|
if (contextMenuFiredRef.current) return;
|
|
@@ -12418,7 +12916,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12418
12916
|
}
|
|
12419
12917
|
setSelectedFeatureIds(nextIds);
|
|
12420
12918
|
selectedFeatureIdsRef.current = nextIds;
|
|
12421
|
-
if (enableProperties) setShowProperties(nextIds.
|
|
12919
|
+
if (enableProperties) setShowProperties(showsPropertiesFor(nextIds, layersRef.current));
|
|
12422
12920
|
scheduleSync("selection");
|
|
12423
12921
|
const selectedFeatures2 = [];
|
|
12424
12922
|
for (const id of nextIds) {
|
|
@@ -12427,7 +12925,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12427
12925
|
if (found) selectedFeatures2.push(found);
|
|
12428
12926
|
});
|
|
12429
12927
|
}
|
|
12430
|
-
|
|
12928
|
+
(_c = onFeatureSelectRef.current) == null ? void 0 : _c.call(onFeatureSelectRef, selectedFeatures2);
|
|
12431
12929
|
requestAnimationFrame(() => {
|
|
12432
12930
|
isSelectingReadOnlyRef.current = false;
|
|
12433
12931
|
});
|
|
@@ -12663,6 +13161,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12663
13161
|
parseGeoJSONText: (label, text) => ingestWithProgress(label, text, { idStrategy: "preserve" }),
|
|
12664
13162
|
addLayer: (name, geojson, options) => {
|
|
12665
13163
|
if (!isMapLoadedRef.current) return "";
|
|
13164
|
+
const hostOwned = (options == null ? void 0 : options.hostOwned) === true;
|
|
13165
|
+
const readOnly = hostOwned ? true : options == null ? void 0 : options.readOnly;
|
|
12666
13166
|
if (options == null ? void 0 : options.recordHistory) saveStateForUndo(`add layer "${name}"`);
|
|
12667
13167
|
const layerId = `layer-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
12668
13168
|
const newLayer = {
|
|
@@ -12675,7 +13175,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12675
13175
|
// visibility toggle).
|
|
12676
13176
|
visible: (options == null ? void 0 : options.visible) ?? true,
|
|
12677
13177
|
featureIds: [],
|
|
12678
|
-
readOnly
|
|
13178
|
+
readOnly,
|
|
13179
|
+
...hostOwned ? { hostOwned: true } : {},
|
|
12679
13180
|
group: options == null ? void 0 : options.group,
|
|
12680
13181
|
metadata: options == null ? void 0 : options.metadata,
|
|
12681
13182
|
// Per-layer visual configs are passed through verbatim so that hosts
|
|
@@ -12692,7 +13193,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12692
13193
|
let capDropped = 0;
|
|
12693
13194
|
if (geojson) {
|
|
12694
13195
|
const max = featureCapRef.current;
|
|
12695
|
-
if (
|
|
13196
|
+
if (readOnly) {
|
|
12696
13197
|
const prepared = prepareFeaturesForLayer(geojson.features, "addLayer", { max });
|
|
12697
13198
|
readOnlyFeatures.current.set(layerId, prepared.features);
|
|
12698
13199
|
layerTemporalCacheRef.current.set(layerId, { featureCount: prepared.features.length, hasTemporal: prepared.hasTemporal });
|
|
@@ -12730,7 +13231,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12730
13231
|
source: "api"
|
|
12731
13232
|
});
|
|
12732
13233
|
}
|
|
12733
|
-
if (newLayer.visible === false && !
|
|
13234
|
+
if (newLayer.visible === false && !readOnly && draw.current && newLayer.featureIds.length > 0) {
|
|
12734
13235
|
const features = newLayer.featureIds.map((id) => draw.current.get(id)).filter(Boolean);
|
|
12735
13236
|
hiddenFeatures.current.set(layerId, features);
|
|
12736
13237
|
newLayer.featureIds.forEach((id) => {
|
|
@@ -12964,7 +13465,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12964
13465
|
...l,
|
|
12965
13466
|
featureIds: l.featureIds.filter((id) => !idSet.has(id))
|
|
12966
13467
|
}));
|
|
12967
|
-
return updated.filter(
|
|
13468
|
+
return updated.filter(keepLayerAfterFeatureRemoval);
|
|
12968
13469
|
});
|
|
12969
13470
|
updateFeatureCount();
|
|
12970
13471
|
scheduleTimelineUpdate();
|
|
@@ -13173,6 +13674,13 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13173
13674
|
scheduleTimelineUpdate();
|
|
13174
13675
|
}
|
|
13175
13676
|
const newFeatureIds = prepared.featureIds;
|
|
13677
|
+
if (selectedFeatureIdsRef.current.length > 0) {
|
|
13678
|
+
const kept = new Set(newFeatureIds);
|
|
13679
|
+
const removed = new Set(layer.featureIds.filter((id) => !kept.has(id)));
|
|
13680
|
+
if (removed.size > 0) {
|
|
13681
|
+
setSelectedFeatureIds((prev) => prev.some((id) => removed.has(id)) ? prev.filter((id) => !removed.has(id)) : prev);
|
|
13682
|
+
}
|
|
13683
|
+
}
|
|
13176
13684
|
const updatedLayers = layersRef.current.map(
|
|
13177
13685
|
(l) => l.id === layerId ? { ...l, featureIds: newFeatureIds, importing: isShardEligible(l, prepared.features.length, shardSizeRef.current) || void 0 } : l
|
|
13178
13686
|
);
|
|
@@ -13450,7 +13958,18 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13450
13958
|
}, [activeEditingLayerId, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, scheduleSync, toast]);
|
|
13451
13959
|
const handleDeleteSelected = useCallback(() => {
|
|
13452
13960
|
if (selectedFeatureIds.length === 0) return;
|
|
13453
|
-
const
|
|
13961
|
+
const { deletableIds, hostRequests } = splitDeleteByOwner(layersRef.current, selectedFeatureIds);
|
|
13962
|
+
const hostUndos = hostRequests.map((request) => {
|
|
13963
|
+
var _a;
|
|
13964
|
+
return (_a = onDeleteRequestRef.current) == null ? void 0 : _a.call(onDeleteRequestRef, request.layerId, request.featureIds);
|
|
13965
|
+
}).filter(isHostDeleteUndo);
|
|
13966
|
+
if (deletableIds.length === 0) {
|
|
13967
|
+
const step = withHostDeleteUndos(null, "delete features", hostUndos);
|
|
13968
|
+
if (step) history.push(step);
|
|
13969
|
+
return;
|
|
13970
|
+
}
|
|
13971
|
+
const keptIds = splitDeleteByOwner(layersRef.current, hostRequests.flatMap((request) => request.featureIds)).hostRequests.flatMap((request) => request.featureIds);
|
|
13972
|
+
const idSet = new Set(deletableIds);
|
|
13454
13973
|
const readOnlyIdSet = /* @__PURE__ */ new Set();
|
|
13455
13974
|
for (const layer of layersRef.current) {
|
|
13456
13975
|
if (!layer.readOnly) continue;
|
|
@@ -13458,10 +13977,15 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13458
13977
|
}
|
|
13459
13978
|
const editableIds = [];
|
|
13460
13979
|
const readOnlyIds = [];
|
|
13461
|
-
for (const id of
|
|
13980
|
+
for (const id of deletableIds) {
|
|
13462
13981
|
(readOnlyIdSet.has(id) ? readOnlyIds : editableIds).push(id);
|
|
13463
13982
|
}
|
|
13464
13983
|
saveStateForUndo("delete features");
|
|
13984
|
+
if (hostUndos.length > 0) {
|
|
13985
|
+
const pending = pendingCaptureRef.current;
|
|
13986
|
+
if (pending) pending.hostUndos = [...pending.hostUndos ?? [], ...hostUndos];
|
|
13987
|
+
else history.push(withHostDeleteUndos(null, "delete features", hostUndos));
|
|
13988
|
+
}
|
|
13465
13989
|
if (editableIds.length > 0 && draw.current) {
|
|
13466
13990
|
editableIds.forEach((id) => {
|
|
13467
13991
|
arrowFeatureIdsRef.current.delete(id);
|
|
@@ -13491,15 +14015,15 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13491
14015
|
...l,
|
|
13492
14016
|
featureIds: l.featureIds.filter((id) => !idSet.has(id))
|
|
13493
14017
|
}));
|
|
13494
|
-
return updated.filter(
|
|
14018
|
+
return updated.filter(keepLayerAfterFeatureRemoval);
|
|
13495
14019
|
});
|
|
13496
|
-
onFeatureDelete == null ? void 0 : onFeatureDelete(
|
|
13497
|
-
setSelectedFeatureIds(
|
|
13498
|
-
setShowProperties(
|
|
14020
|
+
onFeatureDelete == null ? void 0 : onFeatureDelete(deletableIds);
|
|
14021
|
+
setSelectedFeatureIds(keptIds);
|
|
14022
|
+
setShowProperties(showsPropertiesFor(keptIds, layersRef.current));
|
|
13499
14023
|
updateFeatureCount();
|
|
13500
14024
|
scheduleTimelineUpdate();
|
|
13501
14025
|
scheduleSync();
|
|
13502
|
-
}, [selectedFeatureIds, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, scheduleSync, onFeatureDelete]);
|
|
14026
|
+
}, [selectedFeatureIds, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, scheduleSync, onFeatureDelete, history]);
|
|
13503
14027
|
const handleToggleEditMode = useCallback(() => {
|
|
13504
14028
|
setIsEditMode((prev) => {
|
|
13505
14029
|
const newMode = !prev;
|
|
@@ -13980,7 +14504,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13980
14504
|
const handleRemoveLayer = useCallback((layerId) => {
|
|
13981
14505
|
if (layers.length <= 1) return;
|
|
13982
14506
|
const layer = layers.find((l) => l.id === layerId);
|
|
13983
|
-
if (!layer || !draw.current) return;
|
|
14507
|
+
if (!layer || isHostOwnedLayer(layer) || !draw.current) return;
|
|
13984
14508
|
saveStateForUndo();
|
|
13985
14509
|
layer.featureIds.forEach((id) => {
|
|
13986
14510
|
try {
|
|
@@ -14056,6 +14580,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14056
14580
|
}
|
|
14057
14581
|
}, [layers, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate]);
|
|
14058
14582
|
const handleMoveFeatureToLayer = useCallback((featureId, targetLayerId) => {
|
|
14583
|
+
if (movableFeatureIds(layersRef.current, [featureId], targetLayerId).length === 0) return;
|
|
14059
14584
|
saveStateForUndo();
|
|
14060
14585
|
setLayers((prev) => {
|
|
14061
14586
|
const updated = prev.map((l) => {
|
|
@@ -14074,8 +14599,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14074
14599
|
var _a;
|
|
14075
14600
|
return ((_a = draw.current) == null ? void 0 : _a.get(id)) ?? getReadOnlyFeatureById(id) ?? void 0;
|
|
14076
14601
|
}, [getReadOnlyFeatureById]);
|
|
14077
|
-
const handleMoveFeaturesToLayer = useCallback((
|
|
14078
|
-
|
|
14602
|
+
const handleMoveFeaturesToLayer = useCallback((requestedIds, targetLayerId) => {
|
|
14603
|
+
const featureIds = movableFeatureIds(layersRef.current, requestedIds, targetLayerId);
|
|
14604
|
+
if (!draw.current || featureIds.length === 0) return;
|
|
14079
14605
|
saveStateForUndo();
|
|
14080
14606
|
const idSet = new Set(featureIds);
|
|
14081
14607
|
const movedIds = [];
|
|
@@ -14114,8 +14640,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14114
14640
|
updateFeatureCount();
|
|
14115
14641
|
}
|
|
14116
14642
|
}, [saveStateForUndo, findFeatureById, updateFeatureCount, scheduleSync]);
|
|
14117
|
-
const handleCopyFeaturesToLayer = useCallback((
|
|
14118
|
-
|
|
14643
|
+
const handleCopyFeaturesToLayer = useCallback((requestedIds, targetLayerId) => {
|
|
14644
|
+
const featureIds = movableFeatureIds(layersRef.current, requestedIds, targetLayerId);
|
|
14645
|
+
if (!draw.current || featureIds.length === 0) return;
|
|
14119
14646
|
saveStateForUndo();
|
|
14120
14647
|
const newIds = [];
|
|
14121
14648
|
featureIds.forEach((id) => {
|
|
@@ -14133,8 +14660,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14133
14660
|
updateFeatureCount();
|
|
14134
14661
|
}
|
|
14135
14662
|
}, [saveStateForUndo, updateFeatureCount, findFeatureById]);
|
|
14136
|
-
const handleCreateLayerAndMoveFeatures = useCallback((
|
|
14137
|
-
|
|
14663
|
+
const handleCreateLayerAndMoveFeatures = useCallback((requestedIds, layerName) => {
|
|
14664
|
+
const featureIds = movableFeatureIds(layersRef.current, requestedIds);
|
|
14665
|
+
if (!draw.current || featureIds.length === 0) return;
|
|
14138
14666
|
const newLayerId = `layer-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
14139
14667
|
const idSet = new Set(featureIds);
|
|
14140
14668
|
saveStateForUndo();
|
|
@@ -14178,8 +14706,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14178
14706
|
updateFeatureCount();
|
|
14179
14707
|
}
|
|
14180
14708
|
}, [saveStateForUndo, findFeatureById, updateFeatureCount, scheduleSync, withAutoColor]);
|
|
14181
|
-
const handleCreateLayerAndCopyFeatures = useCallback((
|
|
14182
|
-
|
|
14709
|
+
const handleCreateLayerAndCopyFeatures = useCallback((requestedIds, layerName) => {
|
|
14710
|
+
const featureIds = movableFeatureIds(layersRef.current, requestedIds);
|
|
14711
|
+
if (!draw.current || featureIds.length === 0) return;
|
|
14183
14712
|
saveStateForUndo();
|
|
14184
14713
|
const newIds = [];
|
|
14185
14714
|
const copiedFeatures = [];
|
|
@@ -14265,7 +14794,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14265
14794
|
);
|
|
14266
14795
|
const labelLayerIds = onlyLayerIds ?? [
|
|
14267
14796
|
...((_a = shardRegistryRef.current) == null ? void 0 : _a.labelLayerIds("all")) ?? ["custom-labels", "custom-labels-pinned"],
|
|
14268
|
-
"custom-arrow-labels"
|
|
14797
|
+
"custom-arrow-labels",
|
|
14798
|
+
HOST_DECORATION_LAYER_IDS.labels
|
|
14269
14799
|
];
|
|
14270
14800
|
try {
|
|
14271
14801
|
labelLayerIds.forEach((id) => {
|
|
@@ -14486,7 +15016,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14486
15016
|
if (!hasArrowFeaturesRef.current || rafId !== null) return;
|
|
14487
15017
|
rafId = requestAnimationFrame(() => {
|
|
14488
15018
|
rafId = null;
|
|
14489
|
-
renderArrowOverlays(paintedArrowLinesRef.current);
|
|
15019
|
+
renderArrowOverlays(paintedArrowLinesRef.current, { headsOnly: true });
|
|
14490
15020
|
});
|
|
14491
15021
|
};
|
|
14492
15022
|
mapInstance.on("move", handleMove);
|
|
@@ -15761,6 +16291,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
15761
16291
|
const layerStates = [];
|
|
15762
16292
|
layers.forEach((layer, idx) => {
|
|
15763
16293
|
var _a;
|
|
16294
|
+
if (isHostOwnedLayer(layer)) return;
|
|
15764
16295
|
const isDataViewing = ((_a = layer.metadata) == null ? void 0 : _a.dataViewing) === true;
|
|
15765
16296
|
if (!isDataViewing) {
|
|
15766
16297
|
const layerFeatures = collectLayerFeatures(layer, {
|
|
@@ -15954,7 +16485,11 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
15954
16485
|
if (draw.current) {
|
|
15955
16486
|
draw.current.deleteAll();
|
|
15956
16487
|
}
|
|
15957
|
-
|
|
16488
|
+
const hostLayers = layersRef.current.filter(isHostOwnedLayer);
|
|
16489
|
+
const hostLayerIds = new Set(hostLayers.map((l) => l.id));
|
|
16490
|
+
for (const layerId of Array.from(readOnlyFeatures.current.keys())) {
|
|
16491
|
+
if (!hostLayerIds.has(layerId)) readOnlyFeatures.current.delete(layerId);
|
|
16492
|
+
}
|
|
15958
16493
|
hiddenFeatures.current.clear();
|
|
15959
16494
|
const featuresByIndex = /* @__PURE__ */ new Map();
|
|
15960
16495
|
enriched.features.forEach((f) => {
|
|
@@ -15975,6 +16510,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
15975
16510
|
let firstTruncatedLayer = "";
|
|
15976
16511
|
for (const ls of sortedLayers) {
|
|
15977
16512
|
if (((_a = ls.metadata) == null ? void 0 : _a.dataViewing) === true) continue;
|
|
16513
|
+
if (isHostOwnedLayer(ls)) continue;
|
|
15978
16514
|
const capped = capFeatures(featuresByIndex.get(ls.index) ?? [], { max: featureCapRef.current });
|
|
15979
16515
|
const rawFeatures = capped.features;
|
|
15980
16516
|
if (capped.dropped > 0) {
|
|
@@ -16025,8 +16561,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
16025
16561
|
readOnly: isReadOnly
|
|
16026
16562
|
});
|
|
16027
16563
|
}
|
|
16028
|
-
layersRef.current = newLayers;
|
|
16029
|
-
setLayers(
|
|
16564
|
+
layersRef.current = [...newLayers, ...hostLayers];
|
|
16565
|
+
setLayers(layersRef.current);
|
|
16030
16566
|
updateFeatureCount();
|
|
16031
16567
|
scheduleTimelineUpdate();
|
|
16032
16568
|
scheduleSync();
|
|
@@ -16310,6 +16846,14 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
16310
16846
|
});
|
|
16311
16847
|
return;
|
|
16312
16848
|
}
|
|
16849
|
+
if (isHostOwnedLayer(targetLayer)) {
|
|
16850
|
+
toast({
|
|
16851
|
+
title: "Can't load into this layer",
|
|
16852
|
+
description: "Another view owns its features. Load the file into another layer.",
|
|
16853
|
+
variant: "destructive"
|
|
16854
|
+
});
|
|
16855
|
+
return;
|
|
16856
|
+
}
|
|
16313
16857
|
if (!targetLayer) {
|
|
16314
16858
|
targetLayer = currentLayers.find((l) => l.visible && !l.readOnly);
|
|
16315
16859
|
}
|
|
@@ -18446,6 +18990,7 @@ export {
|
|
|
18446
18990
|
DEFAULT_MAX_FEATURES_PER_LAYER,
|
|
18447
18991
|
DebugSidebar,
|
|
18448
18992
|
DrawingToolbar,
|
|
18993
|
+
HOST_IMAGE_PREFIX,
|
|
18449
18994
|
INTERNAL_PROPERTY_KEYS,
|
|
18450
18995
|
INTERNAL_PROPERTY_PREFIXES,
|
|
18451
18996
|
IconPicker,
|