Week 13 October 15 2016

Layer control in leaflet powered maps

library(leaflet)
library(raster)
## Loading required package: sp
fctplaces<-shapefile("C:/shapefiles/fctplaces.shp")
fct<-shapefile("C:/states shapefiles/fct.shp")
leaflet() %>% addTiles(attribution = "overlay data@mapsnigeriainitiative") %>%
  addCircleMarkers(data = fctplaces, stroke = TRUE, color = "#813",popup = paste0("Name: ", fctplaces$name), group = "fctplaces") %>%
  addPolygons(data = fct, weight = 1, fill = TRUE, stroke = TRUE, color = "f93",
              popup = paste0("Name: ", fct$name_2), group = "fct") %>%
      addLayersControl(
    overlayGroups = c("fctplaces", "fct"),
    options = layersControlOptions(collapsed = FALSE)
  )
plot of chunk unnamed-chunk-1