|
@@ -4,6 +4,9 @@ library(leaflet)
|
4
|
4
|
library(dplyr)
|
5
|
5
|
library(shinyWidgets)
|
6
|
6
|
library(htmltools)
|
|
7
|
+library(rgdal)
|
|
8
|
+library(rgeos)
|
|
9
|
+library(ggfortify)
|
7
|
10
|
|
8
|
11
|
leafcols <- c("blue", "red", "darkred", "lightred",
|
9
|
12
|
"orange", "beige", "green", "darkgreen",
|
|
@@ -33,6 +36,7 @@ snargcol <- function(snarg) {
|
33
|
36
|
sdf
|
34
|
37
|
}
|
35
|
38
|
|
|
39
|
+dhb2015 <- readRDS("dhb2015.rds")
|
36
|
40
|
|
37
|
41
|
popups <- function(data) {
|
38
|
42
|
sprintf("<strong>%s</strong><br/>%s<br/>DHB: %s<br/>%s",
|
|
@@ -90,12 +94,16 @@ ui <- fillPage(title = "New Zealand GP Practice Locations 2017",
|
90
|
94
|
|
91
|
95
|
server <- function(input, output, session) {
|
92
|
96
|
output$medmap <- renderLeaflet({
|
93
|
|
- gl <- leaflet(Geo2017)
|
|
97
|
+ gl <- leaflet(Geo2017) %>%
|
|
98
|
+ addMapPane("polygons", zIndex = 420) %>%
|
|
99
|
+ addMapPane("markers", zIndex = 430)
|
94
|
100
|
gl <- addTiles(gl)
|
95
|
101
|
gl <- addCircleMarkers(gl, lng = Geo2017$lon,
|
96
|
102
|
lat = Geo2017$lat,
|
97
|
103
|
popup = popups(Geo2017),
|
98
|
|
- col= "blue")
|
|
104
|
+ col= "blue",
|
|
105
|
+ #pathOptions(pane = "markers")
|
|
106
|
+ )
|
99
|
107
|
gl
|
100
|
108
|
})
|
101
|
109
|
|
|
@@ -111,20 +119,24 @@ server <- function(input, output, session) {
|
111
|
119
|
lat = Geo2017$lat,
|
112
|
120
|
popup = popups(Geo2017),
|
113
|
121
|
# color = snargcols[as.character(Geo2017$dhb_name)]
|
114
|
|
- col = snargcol(Geo2017$Snargle)
|
|
122
|
+ col = snargcol(Geo2017$Snargle),
|
|
123
|
+ #pathOptions(pane = "markers")
|
115
|
124
|
)
|
116
|
125
|
} else if (input$selcol == "DHB") {
|
117
|
126
|
gl <- addCircleMarkers(gl, lng = Geo2017$lon,
|
118
|
127
|
lat = Geo2017$lat,
|
119
|
128
|
popup = popups(Geo2017),
|
120
|
129
|
# color = dhbcols[Geo2017$dhb_name]
|
121
|
|
- col = dhbcol(Geo2017$dhb_name)
|
|
130
|
+ col = dhbcol(Geo2017$dhb_name),
|
|
131
|
+ #pathOptions(pane = "markers")
|
122
|
132
|
)
|
123
|
133
|
} else {
|
124
|
134
|
gl <- addCircleMarkers(gl, lng = Geo2017$lon,
|
125
|
135
|
lat = Geo2017$lat,
|
126
|
136
|
popup = popups(Geo2017),
|
127
|
|
- col= "blue")
|
|
137
|
+ col= "blue",
|
|
138
|
+ #pathOptions(pane = "markers")
|
|
139
|
+ )
|
128
|
140
|
}
|
129
|
141
|
})
|
130
|
142
|
|
|
@@ -143,6 +155,17 @@ server <- function(input, output, session) {
|
143
|
155
|
zoom = 13)
|
144
|
156
|
}
|
145
|
157
|
})
|
|
158
|
+ observeEvent(input$dhboverlay, {
|
|
159
|
+ if (input$dhboverlay) {
|
|
160
|
+ leafletProxy("medmap") %>% addPolygons(data = dhbsub, fill = FALSE,
|
|
161
|
+ color = "#000000",
|
|
162
|
+ weight = 2,
|
|
163
|
+ #pathOptions(pane = "polygons")
|
|
164
|
+ )
|
|
165
|
+ } else {
|
|
166
|
+ leafletProxy("medmap") %>% clearShapes()
|
|
167
|
+ }
|
|
168
|
+ })
|
146
|
169
|
|
147
|
170
|
}
|
148
|
171
|
|