Trying to replicate the action of an Leaflet easybutton (as show on the leaflet for R Github additional features), where the user clicks the easybutton and it zooms to their location.
Id like to replicate this but with a custom html button and JS in the tags$script.
No luck so far, efforts so far:
library(shiny)
library(leaflet)
ui <- fluidPage(
leafletOutput("mymap"),
absolutePanel(id = "button_1", top = "2%", right = "2%", fixed = TRUE,
HTML('<p> <button class="btn btn-large btn-primary" type="button" id="button1"><i class="icon-star"></i>Large button</button></p>'),
singleton(tags$script(HTML('$("button1").on("click", function(btn, map){ map.locate({setView: true}));')))
)
)
server <- function(input, output, session) {
output$mymap <- renderLeaflet({
leaflet() %>%
addProviderTiles(providers$Stamen.TonerLite
)
})
}
shinyApp(ui, server)