|
@@ -106,6 +106,10 @@ ui <- fillPage(title = "New Zealand GP Practice Locations 2017",
|
106
|
106
|
"DHB affiliation" = "DHB",
|
107
|
107
|
"Snargleflagen" = "Snargleflagen")),
|
108
|
108
|
hr(),
|
|
109
|
+ radioButtons("overlay", "Show overlay",
|
|
110
|
+ choices = c("None" = "None",
|
|
111
|
+ "DHB boundaries" = "DHB-boundaries")),
|
|
112
|
+ hr(),
|
109
|
113
|
actionLink("closedrop", label = "close", icon = icon("close"),
|
110
|
114
|
style="float:right"),
|
111
|
115
|
circle=FALSE, inputId = "ddown", right = TRUE,
|
|
@@ -113,6 +117,8 @@ ui <- fillPage(title = "New Zealand GP Practice Locations 2017",
|
113
|
117
|
leafletOutput(outputId = "medmap")
|
114
|
118
|
)
|
115
|
119
|
|
|
120
|
+# Store group name of overlays that have been loaded
|
|
121
|
+loaded.overlays <- c()
|
116
|
122
|
|
117
|
123
|
server <- function(input, output, session) {
|
118
|
124
|
output$medmap <- renderLeaflet({
|
|
@@ -163,6 +169,23 @@ server <- function(input, output, session) {
|
163
|
169
|
}
|
164
|
170
|
})
|
165
|
171
|
|
|
172
|
+ observeEvent(input$overlay, {
|
|
173
|
+ gl <- leafletProxy("medmap")
|
|
174
|
+ for (g in loaded.overlays) {
|
|
175
|
+ hideGroup(gl, g)
|
|
176
|
+ }
|
|
177
|
+ if (input$overlay == "DHB-boundaries") {
|
|
178
|
+ if (input$overlay %in% loaded.overlays) {
|
|
179
|
+ showGroup(gl, input$overlay)
|
|
180
|
+ } else {
|
|
181
|
+ dhb2015 <- readRDS("dhb2015.rds") %>% subset(dhb2015$DHB2015_Co != "99")
|
|
182
|
+ addPolygons(gl, data = dhb2015, fill = FALSE,
|
|
183
|
+ color = "#000000", weight = 2,
|
|
184
|
+ group = input$overlay)
|
|
185
|
+ loaded.overlays <<- c(loaded.overlays, input$overlay)
|
|
186
|
+ }
|
|
187
|
+ }
|
|
188
|
+ })
|
166
|
189
|
}
|
167
|
190
|
|
168
|
191
|
# Run the application
|