@octostar/map-component 0.1.25 → 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 +24 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +24 -15
- 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.mjs
CHANGED
|
@@ -5531,6 +5531,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
5531
5531
|
onWorkspaceSave,
|
|
5532
5532
|
getAdditionalSaveState,
|
|
5533
5533
|
onMapStateLoaded,
|
|
5534
|
+
interceptGeoJSONFileLoad,
|
|
5534
5535
|
entityCardProvider,
|
|
5535
5536
|
typePickerProvider,
|
|
5536
5537
|
contextMenuProvider,
|
|
@@ -10933,7 +10934,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10933
10934
|
const handleFileChange = useCallback((e) => {
|
|
10934
10935
|
var _a;
|
|
10935
10936
|
const file = (_a = e.target.files) == null ? void 0 : _a[0];
|
|
10936
|
-
if (!file
|
|
10937
|
+
if (!file) return;
|
|
10937
10938
|
const requestedTargetLayerId = e.target.dataset.targetLayer || activeEditingLayerId;
|
|
10938
10939
|
const createNewLayer = e.target.dataset.createNewLayer === "true";
|
|
10939
10940
|
delete e.target.dataset.createNewLayer;
|
|
@@ -10954,9 +10955,14 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10954
10955
|
return;
|
|
10955
10956
|
}
|
|
10956
10957
|
if (rawGeojson["octostar:map"]) {
|
|
10958
|
+
if (interceptGeoJSONFileLoad != null && interceptGeoJSONFileLoad({ kind: "enriched", data: rawGeojson, file }) === true) {
|
|
10959
|
+
return;
|
|
10960
|
+
}
|
|
10961
|
+
if (!draw.current) return;
|
|
10957
10962
|
restoreEnrichedGeoJSON(rawGeojson);
|
|
10958
10963
|
return;
|
|
10959
10964
|
}
|
|
10965
|
+
if (!draw.current) return;
|
|
10960
10966
|
const { features: geojson, reprojected, sourceCRS } = detectAndReprojectGeoJSON(rawGeojson);
|
|
10961
10967
|
saveStateForUndo();
|
|
10962
10968
|
const layerMetadata = (_b = rawGeojson.properties) == null ? void 0 : _b.layerMetadata;
|
|
@@ -10976,6 +10982,15 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10976
10982
|
};
|
|
10977
10983
|
});
|
|
10978
10984
|
if (createNewLayer) {
|
|
10985
|
+
if (interceptGeoJSONFileLoad != null && interceptGeoJSONFileLoad({
|
|
10986
|
+
kind: "newLayer",
|
|
10987
|
+
data: { type: "FeatureCollection", features: normalizedFeatures },
|
|
10988
|
+
file,
|
|
10989
|
+
reprojected,
|
|
10990
|
+
sourceCRS: sourceCRS ?? void 0
|
|
10991
|
+
}) === true) {
|
|
10992
|
+
return;
|
|
10993
|
+
}
|
|
10979
10994
|
const fileName = file.name.replace(/\.geojson$|\.json$/i, "");
|
|
10980
10995
|
const layerId = `layer-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
10981
10996
|
const newLayer = {
|
|
@@ -11089,11 +11104,14 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11089
11104
|
};
|
|
11090
11105
|
reader.readAsText(file);
|
|
11091
11106
|
e.target.value = "";
|
|
11092
|
-
}, [layers, activeEditingLayerId, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, restoreEnrichedGeoJSON, toast]);
|
|
11107
|
+
}, [layers, activeEditingLayerId, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, restoreEnrichedGeoJSON, toast, interceptGeoJSONFileLoad]);
|
|
11093
11108
|
const handleDropGeoJSON = useCallback((name, data) => {
|
|
11094
11109
|
var _a;
|
|
11095
11110
|
if (!map.current) return;
|
|
11096
11111
|
if (data["octostar:map"]) {
|
|
11112
|
+
if (interceptGeoJSONFileLoad != null && interceptGeoJSONFileLoad({ kind: "enriched", data, sourceName: name }) === true) {
|
|
11113
|
+
return;
|
|
11114
|
+
}
|
|
11097
11115
|
restoreEnrichedGeoJSON(data);
|
|
11098
11116
|
return;
|
|
11099
11117
|
}
|
|
@@ -11164,7 +11182,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11164
11182
|
title: "Layer added",
|
|
11165
11183
|
description: `Created "${newLayer.name}" with ${addedIds.length} features${reprojectMsg} (high-performance)`
|
|
11166
11184
|
});
|
|
11167
|
-
}, [saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, restoreEnrichedGeoJSON, toast]);
|
|
11185
|
+
}, [saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, restoreEnrichedGeoJSON, toast, interceptGeoJSONFileLoad]);
|
|
11168
11186
|
const handleTimelineFilterChange = useCallback((visibleIds, hiddenIds, untimedIds) => {
|
|
11169
11187
|
if (!draw.current || !map.current) return;
|
|
11170
11188
|
timelineVisibleIdsRef.current = /* @__PURE__ */ new Set([...visibleIds, ...untimedIds]);
|
|
@@ -11409,18 +11427,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11409
11427
|
];
|
|
11410
11428
|
});
|
|
11411
11429
|
}
|
|
11412
|
-
const
|
|
11413
|
-
const
|
|
11414
|
-
const
|
|
11415
|
-
const cappedZoom = Math.min(mapStyleMaxZoom, CLUSTER_ZOOM_CAP);
|
|
11416
|
-
let clusterMaxZoom = Math.max(1, Math.floor(cappedZoom) - 1);
|
|
11417
|
-
let geojsonSourceMaxZoom = Math.min(
|
|
11418
|
-
CLUSTER_ZOOM_CAP,
|
|
11419
|
-
Math.max(clusterMaxZoom + 1, Math.ceil(cappedZoom))
|
|
11420
|
-
);
|
|
11421
|
-
if (clusterMaxZoom >= geojsonSourceMaxZoom) {
|
|
11422
|
-
clusterMaxZoom = Math.max(1, geojsonSourceMaxZoom - 1);
|
|
11423
|
-
}
|
|
11430
|
+
const mapStyleMaxZoom = typeof mapInstance.getMaxZoom === "function" ? mapInstance.getMaxZoom() : 24;
|
|
11431
|
+
const clusterMaxZoom = Math.min(24, Math.max(1, mapStyleMaxZoom - 1));
|
|
11432
|
+
const geojsonSourceMaxZoom = Math.min(24, Math.max(clusterMaxZoom + 1, mapStyleMaxZoom));
|
|
11424
11433
|
mapInstance.addSource(sourceId, {
|
|
11425
11434
|
type: "geojson",
|
|
11426
11435
|
data: { type: "FeatureCollection", features: pointFeatures },
|