I tired and I'm getting the result but with some colors are missing on the leaflet map. The total points are shown on the map. There is one color that is not showing from the list and same thing happens if I use more colors!
Any hints to make it work properly?
library(dplyr)
library(stringr)
library(leaflet.extras)
start_stations <-
data.frame(
station = c("StreeterDr", "MichiganAve", "WellsSt", "Highwayzone"),
lat = c(25.27091982, 25.28078061, 25.2842742,25.28212071),
lng = c(51.53083782,51.51318414,51.50223763,51.54843926),
status = c("high", "medium", "low", "extreme"),
status_code = c(1, 2, 3, 4)
)
start_stations <- start_stations %>%
mutate(color = case_when(str_detect(status, "high") ~ "blue",
str_detect(status, "medium") ~ "red",
str_detect(status, "low") ~ "green",
str_detect(status, "extreme") ~ "yellow",
TRUE ~ "a default"))
icons <- awesomeIcons(
icon = 'ios-close',
iconColor = 'black',
library = 'ion',
markerColor = start_stations$color
)
library(leaflet)
leaflet(start_stations) %>%
addProviderTiles("OpenStreetMap.France") %>%
setView(lng = 51.1966577 , lat = 25.3271054, zoom = 8) %>%# base coordinates
addAwesomeMarkers(
icon = icons,
lng = ~lng,
lat = ~lat,
label = ~start_stations$status
)
NOTE:
I have seen a solution here in this link and followed but mine is not working!