Skip to content

Error in vapply() when trying to use add_circle_layer() on data containing lat/lon only #212

Description

@etiennebacher

Hello, I was trying to use add_circle_layer() to add a few points on a map and noticed that it would error if the data contained at least two rows and only columns for latitude and longitude.

Works (lat/lon + one column):

library(mapgl)

map_dat <- data.frame(lat = c(45, 50), lon = c(-45, 50), foo = 1:2) |>
  sf::st_as_sf(coords = c("lon", "lat"), crs = 4326) 

maplibre(projection = "mercator") |>
  add_circle_layer(id = "poi-layer", source = map_dat) 

Fails (lat/lon only):

library(mapgl)

map_dat <- data.frame(lat = c(45, 50), lon = c(-45, 50)) |>
  sf::st_as_sf(coords = c("lon", "lat"), crs = 4326) 

maplibre(projection = "mercator") |>
  add_circle_layer(id = "poi-layer", source = map_dat) 

# Error in `vapply()`:
# ! values must be length 1,
#  but FUN(X[[2]]) result is length 2

I don't use any other feature of the data in add_circle_layer() so this error looks like a bug to me.


mapgl 0.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions