Closed l90tdr closed 4 years ago
You need to include legend = js
in one of the layers
Hi,
Ye I had already tried positioning legend = js
in both layers as well as one or the other, but it still doesn't render it on the browser viewer. Sorry for omitting in the original post. Any ideas?
mapdeck( token = key, style = 'mapbox://styles/mapbox/dark-v9', pitch = 0 ) %>%
add_arc(
data = east
, layer_id = "east"
, origin = c("start_lon", "start_lat")
, destination = c("end_lon", "end_lat")
, stroke_from = "#FFFFFF"
, stroke_to = "#FFFFFF"
, tilt = -30
, legend = js
) %>%
add_arc(
data = west
, layer_id = "west"
, origin = c("start_lon", "start_lat")
, destination = c("end_lon", "end_lat")
, stroke_from = "#00FF00"
, stroke_to = "#00FF00"
, tilt = +30
, legend = js
)
Does this example work for you
url <- 'https://raw.githubusercontent.com/plotly/datasets/master/2011_february_aa_flight_paths.csv'
flights <- read.csv(url)
flights$id <- seq_len(nrow(flights))
flights$stroke <- sample(1:3, size = nrow(flights), replace = T)
flights$info <- paste0("<b>",flights$airport1, " - ", flights$airport2, "</b>")
l1 <- legend_element(variables = c("Eastward", "Westward")
,colours = c("#FFFFFF", "#00FF00")
,colour_type = "fill"
,variable_type = "category"
,title = "Direction of Movement"
)
js <- mapdeck_legend(l1)
js
mapdeck( style = mapdeck_style("dark"), pitch = 45 ) %>%
add_animated_arc(
data = flights
, layer_id = "arc_layer"
, origin = c("start_lon", "start_lat")
, destination = c("end_lon", "end_lat")
, stroke_from = "#FFFFFF"
, stroke_to = "#FFFFFF"
, stroke_width = "stroke"
, trail_length = 10
, legend = js
)
Rookie alert... Both manual legend examples work, just remember to scroll down on viewer if it's out of sight... Thanks dcooley for providing quick assistance! Closing
hah - that's a new one!
Hi, how may I help?
Hi,
New with mapdeck and getting used to the awesome features here.
I have an issue with arc/animated arc legends. Arcs produced from the east and west dataset are coloured with one hex colour (see below code). I don't need any additional info from the points, thus I'd like to reproduce a legend similar to that of #301 where the legend highlights the two hex colours and their respective direction. Is that possible for arcs?
I tried creating this;
but it didn't work.
Note east and west have been separated so that the tilt argument works such that the arc direction avoids going over land. Below code works perfectly for visualisation, but all attempts at adding the legend didn't work.
Appreciate any insight and apologies in advance is this is an easy fix.
Cheers