Browse Source

add search etc

Petra Lamborn 3 years ago
parent
commit
6fa8a74f5d
2 changed files with 20 additions and 10 deletions
  1. 17
    10
      viz/app.R
  2. 3
    0
      viz/extras.R

+ 17
- 10
viz/app.R View File

@@ -115,9 +115,16 @@ server <- function(input, output) {
115 115
                                 fillColor = startcols.res, 
116 116
                   layerId = ~SA22018_V1,
117 117
                   label = shpf@data$SA22018__1,
118
-                  fillOpacity = 1) %>%
118
+                  fillOpacity = 1, group = "polys") %>%
119 119
       setView(174, -41, 6) %>%
120
-        addResetMapButton() %>%
120
+      addResetMapButton() %>%
121
+      addSearchFeatures("polys", 
122
+                        options = searchFeaturesOptions(
123
+                          hideMarkerOnCollapse = TRUE,
124
+                          autoCollapse = FALSE,
125
+                          openPopup = FALSE,
126
+                          zoom=11,
127
+                          position="topleft")) %>%
121 128
       addLegend(position = "topleft",
122 129
                 colors = c(tencols, "#808080"),
123 130
                 labels = transport.t, opacity = 1,
@@ -477,7 +484,7 @@ server <- function(input, output) {
477 484
             ttype <- ifelse(is.na(fdf$MAX) || nrow(fdf) == 0, 0, fdf$MAX)
478 485
             pmp <- ""
479 486
             if (ttype != 0) {
480
-              pmp <- sprintf("Primary mode of transport: %s", 
487
+              pmp <- sprintf("Most common mode of transport: %s", 
481 488
                              transport.t[ttype])
482 489
             }
483 490
             HTML(sprintf("%s<p><em>%d people commute to employment from 
@@ -489,7 +496,7 @@ server <- function(input, output) {
489 496
             ttype <- ifelse(is.na(fdf$MAX) || nrow(fdf) == 0, 0, fdf$MAX)
490 497
             pmp <- ""
491 498
             if (ttype != 0) {
492
-              pmp <- sprintf("Primary mode of transport: %s", 
499
+              pmp <- sprintf("Most common mode of transport: %s", 
493 500
                              transport.t[ttype])
494 501
             }
495 502
             HTML(sprintf("%s<p><em>%d people commute to employment in 
@@ -504,7 +511,7 @@ server <- function(input, output) {
504 511
             ttype <- ifelse(is.na(fdf$MAX) || nrow(fdf) == 0, 0, fdf$MAX)
505 512
             pmp <- ""
506 513
             if (ttype != 0) {
507
-              pmp <- sprintf("Primary mode of transport: %s", 
514
+              pmp <- sprintf("Most common mode of transport: %s", 
508 515
                              edu.t[ttype])
509 516
             }
510 517
             HTML(sprintf("%s<p><em>%d people commute to education from 
@@ -516,7 +523,7 @@ server <- function(input, output) {
516 523
             ttype <- ifelse(is.na(fdf$MAX) || nrow(fdf) == 0, 0, fdf$MAX)
517 524
             pmp <- ""
518 525
             if (ttype != 0) {
519
-              pmp <- sprintf("Primary mode of transport: %s", 
526
+              pmp <- sprintf("Most common mode of transport: %s", 
520 527
                              edu.t[ttype])
521 528
             }
522 529
             HTML(sprintf("%s<p><em>%d people commute to education in 
@@ -536,7 +543,7 @@ server <- function(input, output) {
536 543
             ttype <- ifelse(is.na(fdf$MAX) || nrow(fdf) == 0, 0, fdf$MAX)
537 544
             pmp <- ""
538 545
             if (ttype != 0) {
539
-              pmp <- sprintf("Primary mode of transport: %s", 
546
+              pmp <- sprintf("Most common mode of transport: %s", 
540 547
                              transport.t[ttype])
541 548
             }
542 549
             HTML(sprintf("%s<p><em>%d people commute to employment 
@@ -549,7 +556,7 @@ server <- function(input, output) {
549 556
             ttype <- ifelse(is.na(fdf$MAX) || nrow(fdf) == 0, 0, fdf$MAX)
550 557
             pmp <- ""
551 558
             if (ttype != 0) {
552
-              pmp <- sprintf("Primary mode of transport: %s", 
559
+              pmp <- sprintf("Most common mode of transport: %s", 
553 560
                              transport.t[ttype])
554 561
             }
555 562
             HTML(sprintf("%s<p><em>%d people commute to employment 
@@ -564,7 +571,7 @@ server <- function(input, output) {
564 571
             ttype <- ifelse(is.na(fdf$MAX) || nrow(fdf) == 0, 0, fdf$MAX)
565 572
             pmp <- ""
566 573
             if (ttype != 0) {
567
-              pmp <- sprintf("Primary mode of transport: %s", 
574
+              pmp <- sprintf("Most common mode of transport: %s", 
568 575
                              edu.t[ttype])
569 576
             }
570 577
             HTML(sprintf("%s<p><em>%d people commute to education 
@@ -577,7 +584,7 @@ server <- function(input, output) {
577 584
             ttype <- ifelse(is.na(fdf$MAX) || nrow(fdf) == 0, 0, fdf$MAX)
578 585
             pmp <- ""
579 586
             if (ttype != 0) {
580
-              pmp <- sprintf("Primary mode of transport: %s", 
587
+              pmp <- sprintf("Most common mode of transport: %s", 
581 588
                              edu.t[ttype])
582 589
             }
583 590
             HTML(sprintf("%s<p><em>%d people commute to education 

+ 3
- 0
viz/extras.R View File

@@ -112,6 +112,9 @@ hr {
112 112
   margin-bottom: 10px;
113 113
   border-top: 1px solid #000;
114 114
 }
115
+.leaflet-control-search {
116
+  box-shadow: none;
117
+}
115 118
 "
116 119
 
117 120
 attribhtml <- '