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

Customizing Delete Layers button in draw #119

Open
rfineman opened this issue Feb 15, 2018 · 2 comments
Open

Customizing Delete Layers button in draw #119

rfineman opened this issue Feb 15, 2018 · 2 comments
Labels

Comments

@rfineman
Copy link

Is there a way to edit the "delete layers" button so that instead of providing the options Save|Cancel|Clear All, it merely clears all by clicking the trash can?

image

@bhaskarvk
Copy link
Contributor

I am afraid not. It's a two step process AFAIK. Please check with original draw authers/repo if there is a known work-around.

@trafficonese
Copy link
Owner

trafficonese commented Apr 2, 2024

Here is a workaround for a Shiny-App. Include this snippet anywhere in your ui.

  tags$script(HTML("
   $(document).ready(function() {
      function waitForElement() {
        var element = document.querySelector('.leaflet-draw-edit-remove');
        if (element) {
          element.addEventListener('click', function() {
            setTimeout(function() {
              var eletoclick = $('.leaflet-draw-actions li a')[3];
              if (eletoclick) {
                eletoclick.click();
              }
            }, 100);
          });
        } else {
          setTimeout(waitForElement, 100);
        }
      }
      waitForElement();
    });
    "))

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

No branches or pull requests

3 participants