@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.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,
@@ -6604,7 +6605,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
6604
6605
  draw.current = drawInstance;
6605
6606
  mapInstance.addSource("custom-features", {
6606
6607
  type: "geojson",
6607
- data: { type: "FeatureCollection", features: [] }
6608
+ data: { type: "FeatureCollection", features: [] },
6609
+ maxzoom: 22
6608
6610
  });
6609
6611
  mapInstance.addLayer({
6610
6612
  id: "custom-polygon-fill",
@@ -6839,7 +6841,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
6839
6841
  });
6840
6842
  mapInstance.addSource("arrow-heads", {
6841
6843
  type: "geojson",
6842
- data: { type: "FeatureCollection", features: [] }
6844
+ data: { type: "FeatureCollection", features: [] },
6845
+ maxzoom: 22
6843
6846
  });
6844
6847
  mapInstance.addLayer({
6845
6848
  id: "custom-arrow-heads",
@@ -6852,7 +6855,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
6852
6855
  });
6853
6856
  mapInstance.addSource("arrow-labels", {
6854
6857
  type: "geojson",
6855
- data: { type: "FeatureCollection", features: [] }
6858
+ data: { type: "FeatureCollection", features: [] },
6859
+ maxzoom: 22
6856
6860
  });
6857
6861
  mapInstance.addLayer({
6858
6862
  id: "custom-arrow-labels",
@@ -6881,7 +6885,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
6881
6885
  });
6882
6886
  mapInstance.addSource("trace-features", {
6883
6887
  type: "geojson",
6884
- data: { type: "FeatureCollection", features: [] }
6888
+ data: { type: "FeatureCollection", features: [] },
6889
+ maxzoom: 22
6885
6890
  });
6886
6891
  mapInstance.addLayer({
6887
6892
  id: "trace-lines",
@@ -10929,7 +10934,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
10929
10934
  const handleFileChange = useCallback((e) => {
10930
10935
  var _a;
10931
10936
  const file = (_a = e.target.files) == null ? void 0 : _a[0];
10932
- if (!file || !draw.current) return;
10937
+ if (!file) return;
10933
10938
  const requestedTargetLayerId = e.target.dataset.targetLayer || activeEditingLayerId;
10934
10939
  const createNewLayer = e.target.dataset.createNewLayer === "true";
10935
10940
  delete e.target.dataset.createNewLayer;
@@ -10950,9 +10955,14 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
10950
10955
  return;
10951
10956
  }
10952
10957
  if (rawGeojson["octostar:map"]) {
10958
+ if (interceptGeoJSONFileLoad != null && interceptGeoJSONFileLoad({ kind: "enriched", data: rawGeojson, file }) === true) {
10959
+ return;
10960
+ }
10961
+ if (!draw.current) return;
10953
10962
  restoreEnrichedGeoJSON(rawGeojson);
10954
10963
  return;
10955
10964
  }
10965
+ if (!draw.current) return;
10956
10966
  const { features: geojson, reprojected, sourceCRS } = detectAndReprojectGeoJSON(rawGeojson);
10957
10967
  saveStateForUndo();
10958
10968
  const layerMetadata = (_b = rawGeojson.properties) == null ? void 0 : _b.layerMetadata;
@@ -10972,6 +10982,15 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
10972
10982
  };
10973
10983
  });
10974
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
+ }
10975
10994
  const fileName = file.name.replace(/\.geojson$|\.json$/i, "");
10976
10995
  const layerId = `layer-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
10977
10996
  const newLayer = {
@@ -11085,11 +11104,14 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
11085
11104
  };
11086
11105
  reader.readAsText(file);
11087
11106
  e.target.value = "";
11088
- }, [layers, activeEditingLayerId, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, restoreEnrichedGeoJSON, toast]);
11107
+ }, [layers, activeEditingLayerId, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, restoreEnrichedGeoJSON, toast, interceptGeoJSONFileLoad]);
11089
11108
  const handleDropGeoJSON = useCallback((name, data) => {
11090
11109
  var _a;
11091
11110
  if (!map.current) return;
11092
11111
  if (data["octostar:map"]) {
11112
+ if (interceptGeoJSONFileLoad != null && interceptGeoJSONFileLoad({ kind: "enriched", data, sourceName: name }) === true) {
11113
+ return;
11114
+ }
11093
11115
  restoreEnrichedGeoJSON(data);
11094
11116
  return;
11095
11117
  }
@@ -11160,7 +11182,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
11160
11182
  title: "Layer added",
11161
11183
  description: `Created "${newLayer.name}" with ${addedIds.length} features${reprojectMsg} (high-performance)`
11162
11184
  });
11163
- }, [saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, restoreEnrichedGeoJSON, toast]);
11185
+ }, [saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, restoreEnrichedGeoJSON, toast, interceptGeoJSONFileLoad]);
11164
11186
  const handleTimelineFilterChange = useCallback((visibleIds, hiddenIds, untimedIds) => {
11165
11187
  if (!draw.current || !map.current) return;
11166
11188
  timelineVisibleIdsRef.current = /* @__PURE__ */ new Set([...visibleIds, ...untimedIds]);
@@ -11234,7 +11256,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
11234
11256
  try {
11235
11257
  mapInstance.addSource(sourceId, {
11236
11258
  type: "geojson",
11237
- data: { type: "FeatureCollection", features: pointFeatures }
11259
+ data: { type: "FeatureCollection", features: pointFeatures },
11260
+ maxzoom: 22
11238
11261
  });
11239
11262
  mapInstance.addLayer({
11240
11263
  id: heatmapLayerId,
@@ -11404,12 +11427,18 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
11404
11427
  ];
11405
11428
  });
11406
11429
  }
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));
11407
11433
  mapInstance.addSource(sourceId, {
11408
11434
  type: "geojson",
11409
11435
  data: { type: "FeatureCollection", features: pointFeatures },
11436
+ maxzoom: geojsonSourceMaxZoom,
11410
11437
  cluster: true,
11411
- clusterMaxZoom: 14,
11438
+ clusterMaxZoom,
11412
11439
  clusterRadius: 50,
11440
+ clusterMinPoints: 2,
11441
+ buffer: 256,
11413
11442
  ...Object.keys(clusterProperties).length > 0 ? { clusterProperties } : {}
11414
11443
  });
11415
11444
  if (groupByField && categoryValues.length > 0) {