|
|
@@ -75,9 +75,9 @@ server <- function(input, output, session) |
|
|
|
{ |
|
|
|
# Create map |
|
|
|
output$map <- renderLeaflet({ |
|
|
|
leaflet(communes, options = leafletOptions(minZoom = 6, maxZoom = 14)) %>% |
|
|
|
leaflet(options = leafletOptions(minZoom = 6, maxZoom = 14)) %>% |
|
|
|
addProviderTiles(providers$CartoDB.Positron) %>% |
|
|
|
#addPolygons(weight = 1, color = "#222222", opacity = .1, fillOpacity = .1, fillColor = "#EEEEEE") %>% |
|
|
|
# addPolygons(weight = 1, color = "#222222", opacity = .1, fillOpacity = .1, fillColor = "#EEEEEE") %>% |
|
|
|
setView(lat = 48.35, lng = 6, zoom = 8) |
|
|
|
}) |
|
|
|
|
|
|
@@ -205,12 +205,23 @@ server <- function(input, output, session) |
|
|
|
}) |
|
|
|
|
|
|
|
# Map |
|
|
|
observe({ |
|
|
|
req(filteredData()) |
|
|
|
|
|
|
|
# observe({ |
|
|
|
# existing <- in_bounds() |
|
|
|
# leafletProxy("map", data = filteredData()) %>% |
|
|
|
# clearShapes() %>% |
|
|
|
# }) |
|
|
|
comm <- communes |
|
|
|
comm@data %>% |
|
|
|
left_join(filteredData()) -> comm@data |
|
|
|
|
|
|
|
comm <- comm[!is.na(comm$n),] |
|
|
|
|
|
|
|
pal <- colorNumeric(palette = topo.colors(100), domain = comm$n, na.color = NA, reverse = T) |
|
|
|
|
|
|
|
leafletProxy("map", data = comm) %>% |
|
|
|
clearShapes() %>% |
|
|
|
clearControls() %>% |
|
|
|
addPolygons(weight = 1, color = "#222222", opacity = .1, fillOpacity = .3, fillColor = ~pal(n)) %>% |
|
|
|
addLegend(position = "topleft", pal = pal, values = ~n) |
|
|
|
}) |
|
|
|
|
|
|
|
# Use a separate observer to recreate the legend as needed. |
|
|
|
# observe({ |
|
|
|