|
@@ -3,16 +3,32 @@ library(leaflet)
|
3
|
3
|
library(dplyr)
|
4
|
4
|
library(shinyWidgets)
|
5
|
5
|
|
|
6
|
+leafcols <- c("blue", "red", "darkred", "lightred",
|
|
7
|
+ "orange", "beige", "green", "darkgreen",
|
|
8
|
+ "lightgreen", "darkblue", "lightblue",
|
|
9
|
+ "purple", "darkpurple", "pink", "cadetblue",
|
|
10
|
+ "white", "gray", "lightgray", "black", "pink", "cyan")
|
|
11
|
+
|
6
|
12
|
Geo2017 <- readRDS("Geo2017.rds")
|
7
|
13
|
Geo2017$Snargle <- c(TRUE, rep(FALSE, 5))
|
8
|
14
|
|
9
|
15
|
DHBs <- sort(unique(Geo2017$dhb_name))
|
10
|
16
|
DHBs <- c(DHBs[DHBs != "Missing"], "Missing")
|
11
|
17
|
|
12
|
|
-dhbcols <- hcl.colors(length(DHBs))
|
|
18
|
+dhbcols <- leafcols[1:length(DHBs)]
|
13
|
19
|
names(dhbcols) <- DHBs
|
14
|
|
-snargcols <- hcl.colors(2)
|
15
|
|
-names(snargcols) <- c(TRUE, FALSE)
|
|
20
|
+dhbcol <- function(DHB) {
|
|
21
|
+ sdf <- dhbcols[DHB]
|
|
22
|
+ names(sdf) <- NULL
|
|
23
|
+ sdf
|
|
24
|
+}
|
|
25
|
+snargcols <- leafcols[1:2]
|
|
26
|
+names(snargcols) <- c(FALSE, TRUE)
|
|
27
|
+snargcol <- function(snarg) {
|
|
28
|
+ sdf <- snargcols[as.character(snarg)]
|
|
29
|
+ names(sdf) <- NULL
|
|
30
|
+ sdf
|
|
31
|
+}
|
16
|
32
|
|
17
|
33
|
|
18
|
34
|
ui <- fillPage(title = "New Zealand GP Practice Locations 2017",
|
|
@@ -70,21 +86,24 @@ server <- function(input, output) {
|
70
|
86
|
gl <- leaflet(Geo2017)
|
71
|
87
|
gl <- addTiles(gl)
|
72
|
88
|
if (input$selcol == "Snargleflagen") {
|
73
|
|
- gl <- addMarkers(gl, lng = Geo2017$lon,
|
|
89
|
+ gl <- addCircleMarkers(gl, lng = Geo2017$lon,
|
74
|
90
|
lat = Geo2017$lat,
|
75
|
91
|
popup = Geo2017$name,
|
76
|
92
|
# color = snargcols[as.character(Geo2017$dhb_name)]
|
|
93
|
+ col = snargcol(Geo2017$Snargle)
|
77
|
94
|
)
|
78
|
95
|
} else if (input$selcol == "DHB") {
|
79
|
|
- gl <- addMarkers(gl, lng = Geo2017$lon,
|
|
96
|
+ gl <- addCircleMarkers(gl, lng = Geo2017$lon,
|
80
|
97
|
lat = Geo2017$lat,
|
81
|
98
|
popup = Geo2017$name,
|
82
|
99
|
# color = dhbcols[Geo2017$dhb_name]
|
|
100
|
+ col = dhbcol(Geo2017$dhb_name)
|
83
|
101
|
)
|
84
|
102
|
} else {
|
85
|
|
- gl <- addMarkers(gl, lng = Geo2017$lon,
|
|
103
|
+ gl <- addCircleMarkers(gl, lng = Geo2017$lon,
|
86
|
104
|
lat = Geo2017$lat,
|
87
|
|
- popup = Geo2017$name)
|
|
105
|
+ popup = Geo2017$name,
|
|
106
|
+ col= "blue")
|
88
|
107
|
}
|
89
|
108
|
gl
|
90
|
109
|
})
|