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( const onFeatureCreate = useCallback(
({ detail }) => { ({ detail }) => {
const { geometry, properties } = detail; const { feature } = detail;
const { geometry, properties } = feature;
if (geometry) { if (
feature &&
feature.geometry &&
detail.featureCollection == featureCollection
) {
createFeatures({ createFeatures({
features: [{ type: 'Feature', geometry, properties }], features: [{ type: 'Feature', geometry, properties }],
external: true external: true
}); });
} }
}, },
[createFeatures] [createFeatures, featureCollection]
); );
const onFeatureUpdate = useCallback( const onFeatureUpdate = useCallback(

View file

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