Upload depth_interactive_map_alpha.R
Browse files- depth_interactive_map_alpha.R +11 -10
depth_interactive_map_alpha.R
CHANGED
|
@@ -279,7 +279,10 @@ TEMPORAL_LAYERS <- list(
|
|
| 279 |
ym_expr = "CAST(date_part('year', date_start) AS INTEGER) * 12 + CAST(date_part('month', date_start) AS INTEGER) - 1",
|
| 280 |
point_ym_expr = "CAST(date_part('year', date_start) AS INTEGER) * 12 + CAST(date_part('month', date_start) AS INTEGER) - 1",
|
| 281 |
kind = "point"),
|
| 282 |
-
"pam-choro" = list(label = "PAM events",
|
|
|
|
|
|
|
|
|
|
| 283 |
table = "dim_pam_mun",
|
| 284 |
ym_expr = "CAST(date_part('year', date) AS INTEGER) * 12 + CAST(date_part('month', date) AS INTEGER) - 1",
|
| 285 |
agg = "SUM(pam_n)",
|
|
@@ -4589,16 +4592,14 @@ server <- function(input, output, session) {
|
|
| 4589 |
dplyr::select(-wkt)
|
| 4590 |
}, error = function(e) { message("PAM ym re-query: ", e$message); NULL })
|
| 4591 |
if (is.null(sf_data)) return()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4592 |
maplibre_proxy("map") |>
|
| 4593 |
-
|
| 4594 |
-
add_fill_layer(
|
| 4595 |
-
id = "pam-choro",
|
| 4596 |
-
source = sf_data,
|
| 4597 |
-
fill_color = pam_qstep_expr(),
|
| 4598 |
-
fill_opacity = 0.7,
|
| 4599 |
-
tooltip = list("concat", "<b>", list("get","municipio"), "</b>",
|
| 4600 |
-
"<br>Irregular migration events: ",
|
| 4601 |
-
list("to-string", list("get","pam_n"))))
|
| 4602 |
}, ignoreNULL = TRUE, ignoreInit = TRUE)
|
| 4603 |
|
| 4604 |
# --- PAM temporal plot (irregular migration events over time) ---------------
|
|
|
|
| 279 |
ym_expr = "CAST(date_part('year', date_start) AS INTEGER) * 12 + CAST(date_part('month', date_start) AS INTEGER) - 1",
|
| 280 |
point_ym_expr = "CAST(date_part('year', date_start) AS INTEGER) * 12 + CAST(date_part('month', date_start) AS INTEGER) - 1",
|
| 281 |
kind = "point"),
|
| 282 |
+
"pam-choro" = list(label = "PAM events",
|
| 283 |
+
# COL_COUNT (#374151) was nearly invisible on the dark
|
| 284 |
+
# strip; use PAM_PAL's mid-teal so the bars actually read.
|
| 285 |
+
color = "#41b6c4",
|
| 286 |
table = "dim_pam_mun",
|
| 287 |
ym_expr = "CAST(date_part('year', date) AS INTEGER) * 12 + CAST(date_part('month', date) AS INTEGER) - 1",
|
| 288 |
agg = "SUM(pam_n)",
|
|
|
|
| 4592 |
dplyr::select(-wkt)
|
| 4593 |
}, error = function(e) { message("PAM ym re-query: ", e$message); NULL })
|
| 4594 |
if (is.null(sf_data)) return()
|
| 4595 |
+
# Swap the source data on the existing pam-choro layer instead of
|
| 4596 |
+
# remove + re-add. mapgl's add_fill_layer creates a source named after
|
| 4597 |
+
# the layer ID; remove_layer doesn't drop the source, so the previous
|
| 4598 |
+
# pattern was hitting "source already exists" on the second activation
|
| 4599 |
+
# and leaving the map in a broken state -- this is what was making the
|
| 4600 |
+
# app appear to freeze whenever PAM was re-enabled.
|
| 4601 |
maplibre_proxy("map") |>
|
| 4602 |
+
set_source(layer_id = "pam-choro", source = sf_data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4603 |
}, ignoreNULL = TRUE, ignoreInit = TRUE)
|
| 4604 |
|
| 4605 |
# --- PAM temporal plot (irregular migration events over time) ---------------
|