@octostar/map-component 0.1.26 → 0.1.27
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 +42 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +42 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/components/map-editor-canvas.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7879,8 +7879,49 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
7879
7879
|
});
|
|
7880
7880
|
},
|
|
7881
7881
|
addFeatures: (layerId, features) => {
|
|
7882
|
+
var _a;
|
|
7882
7883
|
const layer = layersRef.current.find((l) => l.id === layerId);
|
|
7883
|
-
if (!layer || !
|
|
7884
|
+
if (!layer || !isMapLoadedRef.current) return [];
|
|
7885
|
+
if (layer.readOnly) {
|
|
7886
|
+
const existing = readOnlyFeatures.current.get(layerId) || [];
|
|
7887
|
+
let layerHasTemporal = ((_a = layerTemporalCacheRef.current.get(layerId)) == null ? void 0 : _a.hasTemporal) ?? false;
|
|
7888
|
+
const newFeaturesWithIds = features.map((f) => {
|
|
7889
|
+
const id = f.id ? String(f.id) : crypto.randomUUID();
|
|
7890
|
+
const props = f.properties || {};
|
|
7891
|
+
if (!hasAnyTemporalValue(props)) {
|
|
7892
|
+
return { ...f, id };
|
|
7893
|
+
}
|
|
7894
|
+
const { startDate, endDate } = normalizeTemporalProperties(props);
|
|
7895
|
+
if (startDate || endDate) layerHasTemporal = true;
|
|
7896
|
+
return {
|
|
7897
|
+
...f,
|
|
7898
|
+
id,
|
|
7899
|
+
properties: {
|
|
7900
|
+
...props,
|
|
7901
|
+
startDate: (startDate == null ? void 0 : startDate.toISOString()) || null,
|
|
7902
|
+
endDate: (endDate == null ? void 0 : endDate.toISOString()) || null
|
|
7903
|
+
}
|
|
7904
|
+
};
|
|
7905
|
+
});
|
|
7906
|
+
const combined = [...existing, ...newFeaturesWithIds];
|
|
7907
|
+
readOnlyFeatures.current.set(layerId, combined);
|
|
7908
|
+
layerTemporalCacheRef.current.set(layerId, { featureCount: combined.length, hasTemporal: layerHasTemporal });
|
|
7909
|
+
const addedIds2 = newFeaturesWithIds.map((f) => String(f.id));
|
|
7910
|
+
const updatedLayers2 = layersRef.current.map(
|
|
7911
|
+
(l) => l.id === layerId ? { ...l, featureIds: [...l.featureIds, ...addedIds2] } : l
|
|
7912
|
+
);
|
|
7913
|
+
layersRef.current = updatedLayers2;
|
|
7914
|
+
setLayers(updatedLayers2);
|
|
7915
|
+
updateFeatureCount();
|
|
7916
|
+
if (layerHasTemporal) {
|
|
7917
|
+
scheduleTimelineUpdate();
|
|
7918
|
+
}
|
|
7919
|
+
requestAnimationFrame(() => {
|
|
7920
|
+
syncRef.current();
|
|
7921
|
+
});
|
|
7922
|
+
return addedIds2;
|
|
7923
|
+
}
|
|
7924
|
+
if (!draw.current) return [];
|
|
7884
7925
|
const addedIds = [];
|
|
7885
7926
|
isApiAddingRef.current = true;
|
|
7886
7927
|
try {
|