-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmp.R
33 lines (27 loc) · 885 Bytes
/
tmp.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
library(shiny)
library(leaflet)
library(sp)
# library(raster)
SpPDF <- st_read("C:/_FORMATIONS/R/shiny/formation_2023/bnvds_app/data/ign_admin_com_202002_4326_simplified_limited.shp")
## UI ##########
ui <- fluidPage(
selectInput("col", label = "Select a color", choices = c("Blues", "viridis", "magma")),
leafletOutput("mymap")
)
## SERVER ##########
server <- function(input, output) {
output$mymap <- renderLeaflet({
leaflet() %>%
addTiles() #%>%
# fitBounds(lng1 = Extent[1],lat1 = Extent[3], lng2 = Extent[2], lat2 = Extent[4])
})
observe({
req(input$col)
click <- input$mymap_shape_click
print(click)
pal = colorFactor(input$col, domain = factor(SpPDF$POPULATION))
leafletProxy("mymap") %>%
addPolygons(data = SpPDF, color = ~pal(factor(SpPDF$POPULATION)))
})
}
shinyApp(ui, server)