forked from bbest/shiny-ck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.R
58 lines (48 loc) · 1.72 KB
/
map.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
load("data/huc12.rda")
load("data/locations.rda")
pop <- paste(
paste("<strong>Watershed:</strong>", data$Watershed),
paste("<strong>Creek:</strong>", data$`Creek or Stream`),
paste("<strong>Site Name:</strong>", data$`Site Name`),
paste("<strong>Site Name:</strong>", data$`Site Code`),
sep = "<br/>"
)
ll = paste(
paste("<strong>Name:</strong>", huc$Name),
paste("<strong>HUC12:</strong>", huc$HUC12),
sep = "<br/>"
)
m = leaflet() %>%
addProviderTiles(providers$CartoDB.Positron, group = "Base") %>%
addProviderTiles(providers$Esri.WorldImagery, group = "Imagery") %>%
addProviderTiles(providers$Esri.NatGeoWorldMap , group = "Terrain") %>%
addScaleBar("bottomleft") %>%
addMiniMap(tiles = providers$OpenStreetMap.BlackAndWhite,
toggleDisplay = TRUE) %>%
addMeasure(
position = "bottomleft",
primaryLengthUnit = "feet",
primaryAreaUnit = "sqmiles",
activeColor = "red",
completedColor = "green"
) %>% addMarkers(data = data, lng = data$lon, lat = data$lat, popup = pop ) %>%
addPolygons( data = huc, fillColor = "lightblue",
color = "black",
stroke = TRUE,
weight = 4,
opacity = 1,
fillOpacity = .5,
smoothFactor = 0.7,
popup = ll,
group = "WBD",
highlight = highlightOptions(
weight = 5,
color = "darkred",
fillOpacity = 0.7,
bringToFront = TRUE
)) %>%
addLayersControl(
baseGroups = c("Base", "Imagery", "Terrain"),
options = layersControlOptions(collapsed = T)
)
m