fix(cartes): PointInput should not add point to all map on page

This commit is contained in:
Martin 2024-02-09 10:37:33 +01:00
parent 6a0b17a3ef
commit 4209eec021
2 changed files with 12 additions and 5 deletions

View file

@ -147,16 +147,20 @@ function useExternalEvents(
const onFeatureCreate = useCallback(
({ detail }) => {
const { geometry, properties } = detail;
if (geometry) {
const { feature } = detail;
const { geometry, properties } = feature;
if (
feature &&
feature.geometry &&
detail.featureCollection == featureCollection
) {
createFeatures({
features: [{ type: 'Feature', geometry, properties }],
external: true
});
}
},
[createFeatures]
[createFeatures, featureCollection]
);
const onFeatureUpdate = useCallback(

View file

@ -23,7 +23,10 @@ export function PointInput({
};
const addPoint = () => {
if (feature) {
fire(document, 'map:feature:create', feature);
fire(document, 'map:feature:create', {
feature,
featureCollection
});
setValue('');
setFeature(null);
}