Created
December 3, 2016 20:55
-
-
Save byzheng/57448dd0cb5f8388a03ea465a0453a1d to your computer and use it in GitHub Desktop.
test shiny for draw plugin
This file contains 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.extras) | |
lat <- c(1, 2, 2, 1) | |
lng <- c(1, 1, 2, 2) | |
library(shiny) | |
library(leaflet) | |
ui <- fluidPage( | |
leafletOutput("mymap"), | |
tags$script(src = 'shiny.js') | |
) | |
server <- function(input, output, session) { | |
output$mymap <- renderLeaflet({ | |
map <- leaflet() %>% | |
addDrawToolbar(targetGroup = 'drawGroup', | |
editOptions = editToolbarOptions()) %>% | |
addPolygons(lat = lat, lng = lng, group = 'drawGroup', layerId= 'AA111') | |
map | |
}) | |
} | |
shinyApp(ui, server) |
This file contains 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
$(document).on('shiny:inputchanged', function(event) { | |
console.log(event.name); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment