Skip to content

[QUESTION] Triggering Draw #180

@cowglow

Description

@cowglow

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions