Created
March 10, 2016 15:37
-
-
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/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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