alexdum commited on
Commit
6362620
·
1 Parent(s): db2b609

refactor: remove inline selected station styling from main layer and add post-render re-highlight.

Browse files
Files changed (1) hide show
  1. server.R +17 -12
server.R CHANGED
@@ -755,21 +755,14 @@ server <- function(input, output, session) {
755
  )
756
 
757
  if (nrow(df) > 0) {
758
- # Add styling columns for selected vs non-selected
759
- # Use isolate to avoid redrawing all stations when selection changes
760
- # (the highlight layer handles selected station visualization)
761
- selected_id <- isolate(current_station_id())
762
- is_selected_vec <- if (!is.null(selected_id)) (df$id == selected_id) else rep(FALSE, nrow(df))
763
-
764
  df <- df %>%
765
  mutate(
766
  circle_color = "navy",
767
- circle_radius = ifelse(is_selected_vec, 10, 6),
768
- circle_stroke_color = ifelse(is_selected_vec, "#FF0000", "#00000000"),
769
- circle_stroke_width = ifelse(is_selected_vec, 3, 0),
770
- is_selected = ifelse(is_selected_vec, 1, 0)
771
- ) %>%
772
- arrange(is_selected)
773
 
774
  # Convert to sf
775
  map_data <- st_as_sf(df, coords = c("longitude", "latitude"), crs = 4326)
@@ -788,6 +781,18 @@ server <- function(input, output, session) {
788
  tooltip = get_column("popup_content"),
789
  before_id = stations_before_id()
790
  )
 
 
 
 
 
 
 
 
 
 
 
 
791
  }
792
 
793
  # Unfreeze after markers are updated
 
755
  )
756
 
757
  if (nrow(df) > 0) {
758
+ # Standard styling for all stations (selection is handled by separate highlight layer)
 
 
 
 
 
759
  df <- df %>%
760
  mutate(
761
  circle_color = "navy",
762
+ circle_radius = 6,
763
+ circle_stroke_color = "#00000000",
764
+ circle_stroke_width = 0
765
+ )
 
 
766
 
767
  # Convert to sf
768
  map_data <- st_as_sf(df, coords = c("longitude", "latitude"), crs = 4326)
 
781
  tooltip = get_column("popup_content"),
782
  before_id = stations_before_id()
783
  )
784
+
785
+ # Re-highlight selected station if present (to update label with new resolution)
786
+ sid <- isolate(current_station_id())
787
+ if (!is.null(sid)) {
788
+ sel_row <- df %>% filter(id == sid)
789
+ if (nrow(sel_row) > 0) {
790
+ highlight_selected_station(maplibre_proxy("map"), sel_row$longitude[1], sel_row$latitude[1], sel_row$popup_content[1], move_map = FALSE)
791
+ } else {
792
+ # Station no longer in filtered set, clear highlight
793
+ maplibre_proxy("map") %>% clear_layer("selected-highlight")
794
+ }
795
+ }
796
  }
797
 
798
  # Unfreeze after markers are updated