library(leaflet.esri)
## Loading required package: leaflet
## Loading required package: leaflet.extras
##get layers
# Map FeatureLayer Names to IDs
#http://portal.gulfcouncil.org/arcgis/rest/services/CoralWorkingGroup/GoliathGrouper/MapServer
layers <- list(
'GC MARFIN 2011-2013' = 0,
'Great Goliath Grouper Count 2010-2015' = 1,
'Mexico Beach Artificial Reef Association 2010-2016' = 2,
'NMFS CRP Grant 2007-2010' = 3,
'Artificial Reefs in Florida' = 4,
'Spring Coast Hardbottom' = 5,
'Coral Hardbottom' = 6,
'50 Meter Bathymetry Contour' = 7
)
## Set zoom and base maps. Many ways to do basemaps...
l <- leaflet() %>%
setView(-87.0369, 28.9072, 5) %>%
#addEsriBasemapLayer(esriBasemapLayers$Imagery)
addTiles('http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
options = providerTileOptions(noWrap = TRUE), group="World Imagery") %>%
addTiles('http://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/Mapserver/tile/{z}/{y}/{x}',
options = providerTileOptions(noWrap = TRUE),group="Labels")
for(i in 1:length(layers)){
#for(i in 1:2){
URL <- paste0('http://portal.gulfcouncil.org/arcgis/rest/services/CoralWorkingGroup/GoliathGrouper/MapServer/', layers[[i]])
l <- l %>% addEsriFeatureLayer(
url=URL,
useServiceSymbology = TRUE , group = names(layers[i]),
options = featureLayerOptions(useCors = FALSE)
)
}
l <- l %>%
#addLayersControl( overlayGroups = names(layers[1:2]),
addLayersControl( overlayGroups = names(layers[1:length(layers)]),
options = layersControlOptions(collapsed=FALSE))
l