trafficonese / leaflet.extras

Extra functionality for leaflet R package.
https://trafficonese.github.io/leaflet.extras/
GNU General Public License v3.0
211 stars 74 forks source link

add new draw options, fix for removeDrawToolbar #184

Closed trafficonese closed 1 year ago

trafficonese commented 4 years ago

Adds handlersOptions and toolbarOptions for addDrawToolbar which let you customize the drawing toolbar / tooltips.

This should close #174

This should also close #148, close #156 and close #165 . The function removeFrom did not exist and was changed to remove and the typo drawToobar was corrected to drawToolbar

claysa commented 4 years ago

Sorry for my ignorance, I'm really new to github... Are these fixes ready to use with the package, or going to be merged with the main branch soon? When that happens will I only need to update the package to be able to use them?

Thanks so much for all your work on this!

trafficonese commented 4 years ago

Unfortunately the package is not well maintained at the moment. Please read the comments of #188.

As soon as the PR is merged, you can install the new version with remotes::install_github("bhaskarvk/leaflet.extras") and once it is published to CRAN, you can run install.packages("leaflet.extras").

If you want to try the PR already, you can install it with remotes::install_github("bhaskarvk/leaflet.extras", ref = remotes::github_pull("184"))

claysa commented 4 years ago

I'm trying the PR and so far so good, this is exactly what I was looking for. Thanks!

nevilamos commented 4 years ago

Hi, I have installed the PRs above - I tried both rsion with remotes::install_github("bhaskarvk/leaflet.extras") and remotes::install_github("bhaskarvk/leaflet.extras", ref = remotes::github_pull("184"))

however neither of them fixed the removeDrawToolbar , with or without clearfeatures =T.

do I understand correctly that using this PR it should be possible to remove the toolbar and the drawn polyong featrue using the following?

leafletProxy('mymap')%>% removeDrawToolbar(clearFeatures = T)

trafficonese commented 4 years ago

Yes, using this PR it should be possible to remove the draw-toolbar and the drawn shapes. This example works for me:

library(shiny)  
library(leaflet)
library(leaflet.extras)

ui <- fluidPage(
  leafletOutput("map"),
  actionButton("rm", "Remove Draw Toolbar")
)

server <- function(input, output, session) {
  output$map <- renderLeaflet({
    leaflet()  %>% 
      addTiles() %>% 
      addDrawToolbar()
  })

  observeEvent(input$rm, {
    leafletProxy('map')%>%
      removeDrawToolbar(clearFeatures = T)
  })
}
shinyApp(ui, server)