Skip to content

Instantly share code, notes, and snippets.

@byzheng
Created March 10, 2016 15:37
Show Gist options
  • Save byzheng/a7ed2057b51e425e309c to your computer and use it in GitHub Desktop.
Save byzheng/a7ed2057b51e425e309c to your computer and use it in GitHub Desktop.
shiny app for drag event using L.Path.Drag. Need to install this fork: https://github.com/byzheng/leaflet/
library(leaflet)
library(shiny)
ui <- fluidPage(
leafletOutput('map'),
verbatimTextOutput('summary')
)
server <- function(input, output, session) {
output$summary <- renderPrint({
#event <- input$map_shape_click
#print(paste(paste(names(event), event, sep = '='), collapse = ', '))
# event <- input$map_shape_dragstart
# print(paste(paste(names(event), event, sep = '='), collapse = ', '))
#
#
# event <- input$map_shape_drag
# print(paste(paste(names(event), event, sep = '='), collapse = ', '))
event <- input$map_shape_dragend
# print(paste(paste(names(event), event, sep = '='), collapse = ', '))
print(event)
})
output$map <- renderLeaflet({
leaflet() %>%
addTiles() %>%
addPolygons(
lng = c(0, 10, 10, 0, 0),
lat = c(0, 0, 10, 10, 0),
options = pathOptions(draggable = TRUE),
layerId = 'Polygon_1'
)
})
}
shinyApp(ui, server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment