Developer007
Developer007

Reputation: 37

Remove marker is disabled after one marker remove from map

I am using the react-leaflet/core library together with the plugin Leaflet-Geoman which using the removalMode to delete the marker from map

Below is my code

import { useLeafletContext } from "@react-leaflet/core";
const Geoman = (props) => {

    const context = useLeafletContext();
     useEffect(() => {
        const leafletContainer = context.layerContainer || context.map;

        (leafletContainer as any).pm.addControls({
            drawMarker: true,
            dragMode: false,
            removalMode: true,
        });
        (leafletContainer as any).pm.Toolbar.buttons.removalMode._button.title = 'Delete Data'";
        
        (leafletContainer as any).on("pm:remove", (e) => { 
            //  Delete code for marker
        });
        
        return (<></>);
};

But it is working for only one time, to do second time need to click again on Remove button

Is there any solution to do it only once sop i can delete multiple markers from map

Upvotes: 0

Views: 346

Answers (0)

Related Questions