@octostar/map-component 0.1.24 → 0.1.26
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 +38 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +38 -9
- package/dist/index.mjs.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/map-editor-api.d.ts +21 -0
- package/dist/types/lib/map-editor-api.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5552,6 +5552,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
5552
5552
|
onWorkspaceSave,
|
|
5553
5553
|
getAdditionalSaveState,
|
|
5554
5554
|
onMapStateLoaded,
|
|
5555
|
+
interceptGeoJSONFileLoad,
|
|
5555
5556
|
entityCardProvider,
|
|
5556
5557
|
typePickerProvider,
|
|
5557
5558
|
contextMenuProvider,
|
|
@@ -6625,7 +6626,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6625
6626
|
draw.current = drawInstance;
|
|
6626
6627
|
mapInstance.addSource("custom-features", {
|
|
6627
6628
|
type: "geojson",
|
|
6628
|
-
data: { type: "FeatureCollection", features: [] }
|
|
6629
|
+
data: { type: "FeatureCollection", features: [] },
|
|
6630
|
+
maxzoom: 22
|
|
6629
6631
|
});
|
|
6630
6632
|
mapInstance.addLayer({
|
|
6631
6633
|
id: "custom-polygon-fill",
|
|
@@ -6860,7 +6862,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6860
6862
|
});
|
|
6861
6863
|
mapInstance.addSource("arrow-heads", {
|
|
6862
6864
|
type: "geojson",
|
|
6863
|
-
data: { type: "FeatureCollection", features: [] }
|
|
6865
|
+
data: { type: "FeatureCollection", features: [] },
|
|
6866
|
+
maxzoom: 22
|
|
6864
6867
|
});
|
|
6865
6868
|
mapInstance.addLayer({
|
|
6866
6869
|
id: "custom-arrow-heads",
|
|
@@ -6873,7 +6876,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6873
6876
|
});
|
|
6874
6877
|
mapInstance.addSource("arrow-labels", {
|
|
6875
6878
|
type: "geojson",
|
|
6876
|
-
data: { type: "FeatureCollection", features: [] }
|
|
6879
|
+
data: { type: "FeatureCollection", features: [] },
|
|
6880
|
+
maxzoom: 22
|
|
6877
6881
|
});
|
|
6878
6882
|
mapInstance.addLayer({
|
|
6879
6883
|
id: "custom-arrow-labels",
|
|
@@ -6902,7 +6906,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6902
6906
|
});
|
|
6903
6907
|
mapInstance.addSource("trace-features", {
|
|
6904
6908
|
type: "geojson",
|
|
6905
|
-
data: { type: "FeatureCollection", features: [] }
|
|
6909
|
+
data: { type: "FeatureCollection", features: [] },
|
|
6910
|
+
maxzoom: 22
|
|
6906
6911
|
});
|
|
6907
6912
|
mapInstance.addLayer({
|
|
6908
6913
|
id: "trace-lines",
|
|
@@ -10950,7 +10955,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10950
10955
|
const handleFileChange = react.useCallback((e) => {
|
|
10951
10956
|
var _a;
|
|
10952
10957
|
const file = (_a = e.target.files) == null ? void 0 : _a[0];
|
|
10953
|
-
if (!file
|
|
10958
|
+
if (!file) return;
|
|
10954
10959
|
const requestedTargetLayerId = e.target.dataset.targetLayer || activeEditingLayerId;
|
|
10955
10960
|
const createNewLayer = e.target.dataset.createNewLayer === "true";
|
|
10956
10961
|
delete e.target.dataset.createNewLayer;
|
|
@@ -10971,9 +10976,14 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10971
10976
|
return;
|
|
10972
10977
|
}
|
|
10973
10978
|
if (rawGeojson["octostar:map"]) {
|
|
10979
|
+
if (interceptGeoJSONFileLoad != null && interceptGeoJSONFileLoad({ kind: "enriched", data: rawGeojson, file }) === true) {
|
|
10980
|
+
return;
|
|
10981
|
+
}
|
|
10982
|
+
if (!draw.current) return;
|
|
10974
10983
|
restoreEnrichedGeoJSON(rawGeojson);
|
|
10975
10984
|
return;
|
|
10976
10985
|
}
|
|
10986
|
+
if (!draw.current) return;
|
|
10977
10987
|
const { features: geojson, reprojected, sourceCRS } = detectAndReprojectGeoJSON(rawGeojson);
|
|
10978
10988
|
saveStateForUndo();
|
|
10979
10989
|
const layerMetadata = (_b = rawGeojson.properties) == null ? void 0 : _b.layerMetadata;
|
|
@@ -10993,6 +11003,15 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10993
11003
|
};
|
|
10994
11004
|
});
|
|
10995
11005
|
if (createNewLayer) {
|
|
11006
|
+
if (interceptGeoJSONFileLoad != null && interceptGeoJSONFileLoad({
|
|
11007
|
+
kind: "newLayer",
|
|
11008
|
+
data: { type: "FeatureCollection", features: normalizedFeatures },
|
|
11009
|
+
file,
|
|
11010
|
+
reprojected,
|
|
11011
|
+
sourceCRS: sourceCRS ?? void 0
|
|
11012
|
+
}) === true) {
|
|
11013
|
+
return;
|
|
11014
|
+
}
|
|
10996
11015
|
const fileName = file.name.replace(/\.geojson$|\.json$/i, "");
|
|
10997
11016
|
const layerId = `layer-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
10998
11017
|
const newLayer = {
|
|
@@ -11106,11 +11125,14 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11106
11125
|
};
|
|
11107
11126
|
reader.readAsText(file);
|
|
11108
11127
|
e.target.value = "";
|
|
11109
|
-
}, [layers, activeEditingLayerId, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, restoreEnrichedGeoJSON, toast]);
|
|
11128
|
+
}, [layers, activeEditingLayerId, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, restoreEnrichedGeoJSON, toast, interceptGeoJSONFileLoad]);
|
|
11110
11129
|
const handleDropGeoJSON = react.useCallback((name, data) => {
|
|
11111
11130
|
var _a;
|
|
11112
11131
|
if (!map.current) return;
|
|
11113
11132
|
if (data["octostar:map"]) {
|
|
11133
|
+
if (interceptGeoJSONFileLoad != null && interceptGeoJSONFileLoad({ kind: "enriched", data, sourceName: name }) === true) {
|
|
11134
|
+
return;
|
|
11135
|
+
}
|
|
11114
11136
|
restoreEnrichedGeoJSON(data);
|
|
11115
11137
|
return;
|
|
11116
11138
|
}
|
|
@@ -11181,7 +11203,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11181
11203
|
title: "Layer added",
|
|
11182
11204
|
description: `Created "${newLayer.name}" with ${addedIds.length} features${reprojectMsg} (high-performance)`
|
|
11183
11205
|
});
|
|
11184
|
-
}, [saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, restoreEnrichedGeoJSON, toast]);
|
|
11206
|
+
}, [saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, restoreEnrichedGeoJSON, toast, interceptGeoJSONFileLoad]);
|
|
11185
11207
|
const handleTimelineFilterChange = react.useCallback((visibleIds, hiddenIds, untimedIds) => {
|
|
11186
11208
|
if (!draw.current || !map.current) return;
|
|
11187
11209
|
timelineVisibleIdsRef.current = /* @__PURE__ */ new Set([...visibleIds, ...untimedIds]);
|
|
@@ -11255,7 +11277,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11255
11277
|
try {
|
|
11256
11278
|
mapInstance.addSource(sourceId, {
|
|
11257
11279
|
type: "geojson",
|
|
11258
|
-
data: { type: "FeatureCollection", features: pointFeatures }
|
|
11280
|
+
data: { type: "FeatureCollection", features: pointFeatures },
|
|
11281
|
+
maxzoom: 22
|
|
11259
11282
|
});
|
|
11260
11283
|
mapInstance.addLayer({
|
|
11261
11284
|
id: heatmapLayerId,
|
|
@@ -11425,12 +11448,18 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11425
11448
|
];
|
|
11426
11449
|
});
|
|
11427
11450
|
}
|
|
11451
|
+
const mapStyleMaxZoom = typeof mapInstance.getMaxZoom === "function" ? mapInstance.getMaxZoom() : 24;
|
|
11452
|
+
const clusterMaxZoom = Math.min(24, Math.max(1, mapStyleMaxZoom - 1));
|
|
11453
|
+
const geojsonSourceMaxZoom = Math.min(24, Math.max(clusterMaxZoom + 1, mapStyleMaxZoom));
|
|
11428
11454
|
mapInstance.addSource(sourceId, {
|
|
11429
11455
|
type: "geojson",
|
|
11430
11456
|
data: { type: "FeatureCollection", features: pointFeatures },
|
|
11457
|
+
maxzoom: geojsonSourceMaxZoom,
|
|
11431
11458
|
cluster: true,
|
|
11432
|
-
clusterMaxZoom
|
|
11459
|
+
clusterMaxZoom,
|
|
11433
11460
|
clusterRadius: 50,
|
|
11461
|
+
clusterMinPoints: 2,
|
|
11462
|
+
buffer: 256,
|
|
11434
11463
|
...Object.keys(clusterProperties).length > 0 ? { clusterProperties } : {}
|
|
11435
11464
|
});
|
|
11436
11465
|
if (groupByField && categoryValues.length > 0) {
|