library(leaflet)
library(sf)
## Linking to GEOS 3.11.2, GDAL 3.8.2, PROJ 9.3.1; sf_use_s2() is TRUE
library(readr)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
###Libraries to call functions

protected<-sf::read_sf("Alaska_DEC_Sensitive_Areas.shp") %>%
  sf::st_transform('+proj=longlat +datum=WGS84')
ST<- sf::read_sf("cb_2018_us_state_500k.shp")%>%
  sf::st_transform('+proj=longlat +datum=WGS84')
ALK<- ST %>%
  dplyr::filter(NAME%in%c("Alaska"))
R1 = sf::read_sf("hyd_toolik_arc101111.shp") %>%
  sf::st_transform('+proj=longlat +datum=WGS84')
R2 = sf::read_sf("Anaktuvuk_Burn_Rivers.shp") %>%
  sf::st_transform('+proj=longlat +datum=WGS84') 
R3 = sf::read_sf("SOA_rivers_levees_AOIs.shp") %>%
  sf::st_transform('+proj=longlat +datum=WGS84') 

### all the files and naming them variables to call

alaska <- c(63.5888, -154.4931)

### intializing alaska

map <- leaflet() %>% ###leaflet function
  addProviderTiles(providers$Esri.WorldTopoMap) %>%
  setView(lng = alaska[2], lat = alaska[1], zoom = 4) %>%
  addMarkers(lng = alaska[2], lat = alaska[1], popup = "ALASKA",
             icon = makeIcon(iconUrl = "http://leafletjs.com/examples/custom-icons/leaf-red.png", iconWidth = 50, iconHeight = 100))%>%
  
  ###Custom icon for the unique icon for Alaska
  
  addPolylines(data=R3,fill=F, color="yellow", opacity=8) %>%
  addPolygons(data=protected, fill=FALSE, color="red", opacity=0.3) %>%
  addPolygons(data=ST, fill=FALSE, color="purple", opacity=0.7) %>%
  addPolygons(data = R1, fill=FALSE, color ="blue", opacity = 1) %>%
  
  ### Outline and highlighting of the major things listed
  
  addMarkers(lng = -154.323502, lat = 60.412697, popup = "Lake Clark National Park and Preserve | Surface Area = 4,030,015AC") %>%
  addMarkers(lng = -154.693756, lat = 58.597813, popup = "Katmai National Park and Preserve |  Surface Area = 4,093,077AC") %>%
  addMarkers(lng = -136.900208, lat = 58.665806, popup = "Glacier Bay National Park and Preserve| Surface Area = 3,283,000AC") %>%
  addMarkers(lng = -142.79843, lat = 65.08979, popup = "Yukon-Charley Rivers National Preserve| Surface Area = 2,525,512AC") %>%
  addMarkers(lng = -134.4895, lat = 57.6853, popup = "Admiralty Island National Monument| Surface Area = 955,747AC") %>%
  addMarkers(lng = -165.408418, lat = 64.497922, popup = "Bering Land Bridge National Preserve | Surface Area = 2,697,391AC") %>%
  addMarkers(lng = -142.985687, lat = 61.710445, popup = "Wrangell-St. Elias National Park & Preserve | Surface Area = 13,175,799AC") %>%
  addMarkers(lng = -153.3241, lat = 67.6855, popup = "Gates Of The Arctic National Park & Preserve | Surface Area = 8,472,506AC") %>%
  addMarkers(lng = -159.213175, lat = 67.406386, popup = "Kobuk Valley National Park | Surface Area = 1,750,716AC") %>%
  addMarkers(lng = -157.814709, lat = 56.870864, popup = "Aniakchak National Monument & Preserve | Surface Area = 601,294AC") %>%
  addMarkers(lng = -149.816360, lat = 60.043777, popup = "Kenai Fjords National Park| Surface Area = 669,984AC") %>%
  addMarkers(lng = -159.9070, lat = 68.1353, popup = "Noatak National Preserve | Surface Area = 6,569,904AC") %>%
  addMarkers(lng = -130.686710, lat = 55.668243, popup = "Misty Fjords National Monument| Surface Area = 2,294,343AC") %>%
  addMarkers(lng = -163.5054, lat = 67.4181, popup = "Cape Krusenstern National Monument | Surface Area = 649,082AC") %>%
  addMarkers(lng = -151.197418, lat = 63.129887, popup = "Denali National Park & Preserve | Surface Area = 6,045,153AC") 

### All of the markers for the protected lands

map ### calling the map function