Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

140
Vistas
replicate Shiny leaflet easybutton 'locate you' but with an custom html button

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)
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda