@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.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,
|
|
@@ -10954,7 +10955,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10954
10955
|
const handleFileChange = react.useCallback((e) => {
|
|
10955
10956
|
var _a;
|
|
10956
10957
|
const file = (_a = e.target.files) == null ? void 0 : _a[0];
|
|
10957
|
-
if (!file
|
|
10958
|
+
if (!file) return;
|
|
10958
10959
|
const requestedTargetLayerId = e.target.dataset.targetLayer || activeEditingLayerId;
|
|
10959
10960
|
const createNewLayer = e.target.dataset.createNewLayer === "true";
|
|
10960
10961
|
delete e.target.dataset.createNewLayer;
|
|
@@ -10975,9 +10976,14 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10975
10976
|
return;
|
|
10976
10977
|
}
|
|
10977
10978
|
if (rawGeojson["octostar:map"]) {
|
|
10979
|
+
if (interceptGeoJSONFileLoad != null && interceptGeoJSONFileLoad({ kind: "enriched", data: rawGeojson, file }) === true) {
|
|
10980
|
+
return;
|
|
10981
|
+
}
|
|
10982
|
+
if (!draw.current) return;
|
|
10978
10983
|
restoreEnrichedGeoJSON(rawGeojson);
|
|
10979
10984
|
return;
|
|
10980
10985
|
}
|
|
10986
|
+
if (!draw.current) return;
|
|
10981
10987
|
const { features: geojson, reprojected, sourceCRS } = detectAndReprojectGeoJSON(rawGeojson);
|
|
10982
10988
|
saveStateForUndo();
|
|
10983
10989
|
const layerMetadata = (_b = rawGeojson.properties) == null ? void 0 : _b.layerMetadata;
|
|
@@ -10997,6 +11003,15 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10997
11003
|
};
|
|
10998
11004
|
});
|
|
10999
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
|
+
}
|
|
11000
11015
|
const fileName = file.name.replace(/\.geojson$|\.json$/i, "");
|
|
11001
11016
|
const layerId = `layer-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
11002
11017
|
const newLayer = {
|
|
@@ -11110,11 +11125,14 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11110
11125
|
};
|
|
11111
11126
|
reader.readAsText(file);
|
|
11112
11127
|
e.target.value = "";
|
|
11113
|
-
}, [layers, activeEditingLayerId, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, restoreEnrichedGeoJSON, toast]);
|
|
11128
|
+
}, [layers, activeEditingLayerId, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, restoreEnrichedGeoJSON, toast, interceptGeoJSONFileLoad]);
|
|
11114
11129
|
const handleDropGeoJSON = react.useCallback((name, data) => {
|
|
11115
11130
|
var _a;
|
|
11116
11131
|
if (!map.current) return;
|
|
11117
11132
|
if (data["octostar:map"]) {
|
|
11133
|
+
if (interceptGeoJSONFileLoad != null && interceptGeoJSONFileLoad({ kind: "enriched", data, sourceName: name }) === true) {
|
|
11134
|
+
return;
|
|
11135
|
+
}
|
|
11118
11136
|
restoreEnrichedGeoJSON(data);
|
|
11119
11137
|
return;
|
|
11120
11138
|
}
|
|
@@ -11185,7 +11203,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11185
11203
|
title: "Layer added",
|
|
11186
11204
|
description: `Created "${newLayer.name}" with ${addedIds.length} features${reprojectMsg} (high-performance)`
|
|
11187
11205
|
});
|
|
11188
|
-
}, [saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, restoreEnrichedGeoJSON, toast]);
|
|
11206
|
+
}, [saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, restoreEnrichedGeoJSON, toast, interceptGeoJSONFileLoad]);
|
|
11189
11207
|
const handleTimelineFilterChange = react.useCallback((visibleIds, hiddenIds, untimedIds) => {
|
|
11190
11208
|
if (!draw.current || !map.current) return;
|
|
11191
11209
|
timelineVisibleIdsRef.current = /* @__PURE__ */ new Set([...visibleIds, ...untimedIds]);
|
|
@@ -11430,18 +11448,9 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11430
11448
|
];
|
|
11431
11449
|
});
|
|
11432
11450
|
}
|
|
11433
|
-
const
|
|
11434
|
-
const
|
|
11435
|
-
const
|
|
11436
|
-
const cappedZoom = Math.min(mapStyleMaxZoom, CLUSTER_ZOOM_CAP);
|
|
11437
|
-
let clusterMaxZoom = Math.max(1, Math.floor(cappedZoom) - 1);
|
|
11438
|
-
let geojsonSourceMaxZoom = Math.min(
|
|
11439
|
-
CLUSTER_ZOOM_CAP,
|
|
11440
|
-
Math.max(clusterMaxZoom + 1, Math.ceil(cappedZoom))
|
|
11441
|
-
);
|
|
11442
|
-
if (clusterMaxZoom >= geojsonSourceMaxZoom) {
|
|
11443
|
-
clusterMaxZoom = Math.max(1, geojsonSourceMaxZoom - 1);
|
|
11444
|
-
}
|
|
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));
|
|
11445
11454
|
mapInstance.addSource(sourceId, {
|
|
11446
11455
|
type: "geojson",
|
|
11447
11456
|
data: { type: "FeatureCollection", features: pointFeatures },
|