Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] Triggering Draw #180

Open
cowglow opened this issue Dec 4, 2023 · 0 comments
Open

[QUESTION] Triggering Draw #180

cowglow opened this issue Dec 4, 2023 · 0 comments

Comments

@cowglow
Copy link

cowglow commented Dec 4, 2023

I've been wondering how I can start the drawing as soon as I display the map. I have a field that expands to reveal the map. So my solution was this:

useEffect(() => {
  const target = document.querySelector(".leaflet-draw-draw-polygon")
  if (active && target) {
    target.dispatchEvent(new Event("click"))
  }
}, [active])

active is a prop that I pass from the parent component and it's a boolean.

I'm curious who else might have some feedback. Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant