0

Using Next.js@12 & leaflet-geoman@2.7

I have a custom toolbar with a number of buttons to enable drawing (polygon, rectangle, marker), when I click a button to start drawing, the first vertex is created before I have a chance to move my cursor and click.

Here is the button. I think the click is propagating through to the map underneath the button? Is there a way to stop this? Menu Button is here:

<Menu.Item
     icon={<IconRectangle size={14}/>}
     onClick={() => {
         map.pm.enableDraw('Rectangle', {
         tooltips: false
         })
     }}>
     Rectangle
</Menu.Item>

1 Answer 1

0

OK, this works. There's a stopPropagation method on the event object.

<Menu.Item
     icon={<IconRectangle size={14}/>}
     onClick={(e) => {
         e.stopPropagation()
         map.pm.enableDraw('Rectangle', {
         tooltips: false
         })
     }}>
     Rectangle
</Menu.Item>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.