|
@@ -18,7 +18,7 @@ DHBs <- sort(unique(Geo2017$dhb_name))
|
18
|
18
|
DHBs <- c(DHBs[DHBs != "Missing"], "Missing")
|
19
|
19
|
|
20
|
20
|
# dhbcols <- leafcols[1:length(DHBs)]
|
21
|
|
-dhbcols <- rainbow(length(DHBs))
|
|
21
|
+dhbcols <- hcl.colors(length(DHBs))
|
22
|
22
|
names(dhbcols) <- DHBs
|
23
|
23
|
dhbcol <- function(DHB) {
|
24
|
24
|
sdf <- dhbcols[DHB]
|
|
@@ -34,6 +34,18 @@ snargcol <- function(snarg) {
|
34
|
34
|
}
|
35
|
35
|
|
36
|
36
|
|
|
37
|
+popups <- function(data) {
|
|
38
|
+sprintf("<strong>%s</strong><br/>%s<br/>DHB: %s<br/>%s",
|
|
39
|
+ htmlEscape(data$name),
|
|
40
|
+ htmlEscape(data$address),
|
|
41
|
+ htmlEscape(ifelse(data$dhb_name == "Missing",
|
|
42
|
+ "None", data$dhb_name)),
|
|
43
|
+ ifelse(data$Snargle,
|
|
44
|
+ "Snargleflagen practice",
|
|
45
|
+ "Non-snargleflagen practice"))
|
|
46
|
+}
|
|
47
|
+
|
|
48
|
+
|
37
|
49
|
ui <- fillPage(title = "New Zealand GP Practice Locations 2017",
|
38
|
50
|
tags$style(type = "text/css",
|
39
|
51
|
"#medmap {
|
|
@@ -70,9 +82,9 @@ ui <- fillPage(title = "New Zealand GP Practice Locations 2017",
|
70
|
82
|
width = "100%"),
|
71
|
83
|
hr(),
|
72
|
84
|
radioButtons("selcol", "Colour by",
|
73
|
|
- choices = c("None",
|
74
|
|
- "DHB",
|
75
|
|
- "Snargleflagen")),
|
|
85
|
+ choices = c("None" = "None",
|
|
86
|
+ "DHB affiliation" = "DHB",
|
|
87
|
+ "Snargleflagen" = "Snargleflagen")),
|
76
|
88
|
hr(),
|
77
|
89
|
checkboxInput("dhboverlay", "Show DHB boundaries"),
|
78
|
90
|
hr(),
|
|
@@ -91,39 +103,21 @@ server <- function(input, output) {
|
91
|
103
|
if (input$selcol == "Snargleflagen") {
|
92
|
104
|
gl <- addCircleMarkers(gl, lng = Geo2017$lon,
|
93
|
105
|
lat = Geo2017$lat,
|
94
|
|
- popup = sprintf("<strong>%s</strong><br/>%s<br/>DHB: %s<br/>%s",
|
95
|
|
- htmlEscape(Geo2017$name),
|
96
|
|
- htmlEscape(Geo2017$address),
|
97
|
|
- htmlEscape(Geo2017$dhb_name),
|
98
|
|
- ifelse(Geo2017$Snargle,
|
99
|
|
- "Snargleflagen",
|
100
|
|
- "Non-snargleflagen")),
|
|
106
|
+ popup = popups(Geo2017),
|
101
|
107
|
# color = snargcols[as.character(Geo2017$dhb_name)]
|
102
|
108
|
col = snargcol(Geo2017$Snargle)
|
103
|
109
|
)
|
104
|
110
|
} else if (input$selcol == "DHB") {
|
105
|
111
|
gl <- addCircleMarkers(gl, lng = Geo2017$lon,
|
106
|
112
|
lat = Geo2017$lat,
|
107
|
|
- popup = sprintf("<strong>%s</strong><br/>%s<br/>DHB: %s<br/>%s",
|
108
|
|
- htmlEscape(Geo2017$name),
|
109
|
|
- htmlEscape(Geo2017$address),
|
110
|
|
- htmlEscape(Geo2017$dhb_name),
|
111
|
|
- ifelse(Geo2017$Snargle,
|
112
|
|
- "Snargleflagen",
|
113
|
|
- "Non-snargleflagen")),
|
|
113
|
+ popup = popups(Geo2017),
|
114
|
114
|
# color = dhbcols[Geo2017$dhb_name]
|
115
|
115
|
col = dhbcol(Geo2017$dhb_name)
|
116
|
116
|
)
|
117
|
117
|
} else {
|
118
|
118
|
gl <- addCircleMarkers(gl, lng = Geo2017$lon,
|
119
|
119
|
lat = Geo2017$lat,
|
120
|
|
- popup = sprintf("<strong>%s</strong><br/>%s<br/>DHB: %s<br/>%s",
|
121
|
|
- htmlEscape(Geo2017$name),
|
122
|
|
- htmlEscape(Geo2017$address),
|
123
|
|
- htmlEscape(Geo2017$dhb_name),
|
124
|
|
- ifelse(Geo2017$Snargle,
|
125
|
|
- "Snargleflagen",
|
126
|
|
- "Non-snargleflagen")),
|
|
120
|
+ popup = popups(Geo2017),
|
127
|
121
|
col= "blue")
|
128
|
122
|
}
|
129
|
123
|
gl
|