-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal.R
69 lines (51 loc) · 1.73 KB
/
global.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
57
58
59
60
library("pkgload")
library("osrm")
library("smoothr")
library("devtools")
library("dplyr")
library("geojsonio")
library("leaflet")
library("magrittr")
library("rmapshaper")
library("sf")
library("shiny")
library("shinythemes")
library("nngeo")
library("shinycssloaders")
library("shinyalert")
# library("mapview")
# library("shinyjs")
source('R/func-helpers.R')
source('R/data-prep.R')
source('R/obj-clicked_points.R')
source('R/obj-routing.R')
options(shiny.autoload.r=FALSE)
lmap = leaflet::leaflet() %>%
leaflet::addProviderTiles(provider = leaflet::providers$CartoDB.Positron, options = providerTileOptions(minZoom = 7)) %>%
#https://stackoverflow.com/questions/44953146/r-leaflet-custom-attribution-string
addTiles(urlTemplate = "",
attribution = 'Routing via <a href="http://project-osrm.org/">OSRM</a> under the <a href="http://opendatacommons.org/licenses/odbl/">ODbL</a>.'
) %>%
leaflet::setView(174.757,-36.847,zoom = 11) %>%
# https://stackoverflow.com/questions/54667968/controlling-the-z-index-of-a-leaflet-heatmap-in-r/54676391
addMapPane("parks", zIndex = 430) %>%
addMapPane("alcho", zIndex = 440) %>%
addMapPane("intersection", zIndex = 420) %>%
addLayersControl(
overlayGroups = c(as.character(1:5)),
options = layersControlOptions(
collapsed = F
)
) %>% removeLayersControl()
for (i in 1:5){
lmap = lmap %>%
leaflet::addPolygons(
data = parks %>% dplyr::filter(GROUPING == i),
stroke=FALSE,
fillColor = "#5fd5a7",
fillOpacity = 0.8,
popup = ~SAPPARK_DATADESCRIPTION,
options = pathOptions(pane = "parks"),
group = as.character(i)
)
}