Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legends don't appear with add_geojson #190

Closed
ds-jim opened this issue May 31, 2019 · 3 comments
Closed

Legends don't appear with add_geojson #190

ds-jim opened this issue May 31, 2019 · 3 comments
Assignees

Comments

@ds-jim
Copy link

ds-jim commented May 31, 2019

I'm trying to add a legend with the Geojson layer but I won't work. It does work in add_polygon, but I need to be working with Geojson for a project.

Example below;

library(mapdeck)
sf <- geojsonsf::geojson_sf( geojson )
sf$width <- sample(1:100, size = nrow(sf), replace = TRUE)
sf$elevation <- sample(100:1000, size = nrow(sf), replace = T)
geo <- geojsonsf::sf_geojson( sf )


             
l1 <- legend_element(variables = 1:4, 
                        colours = c("#92637C", "#3A7FB9", "#5872A3", "#B5C9E3"),
                        colour_type = "fill",
                        variable_type = "category")

js <- mapdeck_legend(l1)

#Legend works
mapdeck(
  location = c(145, -37.9)
 , zoom = 8
 , style = mapdeck_style("dark")
 , pitch = 35
) %>% 
   add_polygon(data = sf,
               fill_colour = "fillColor",
               legend = js)

#No legend
mapdeck(
  location = c(145, -37.9)
 , zoom = 8
 , style = mapdeck_style("dark")
 , pitch = 35
) %>%
 add_geojson(
   data = geo,
   layer_id = "diabetes",
   legend = js
 )
@dcooley dcooley self-assigned this May 31, 2019
@dcooley
Copy link
Collaborator

dcooley commented May 31, 2019

I've just pushed an update - try it now.

I'll be making some changes over the coming days but I'll try and keep your example working.

@ds-jim
Copy link
Author

ds-jim commented May 31, 2019

Thank you, that's worked a treat. Appreciate the fast turn around!

@ds-jim ds-jim closed this as completed May 31, 2019
@dcooley
Copy link
Collaborator

dcooley commented Jun 1, 2019

going to keep this open as I need to update the documentation.

@dcooley dcooley reopened this Jun 1, 2019
@dcooley dcooley closed this as completed in 1d9468b Jun 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants