qfes / rdeck

Deck.gl widget for R
https://qfes.github.io/rdeck
MIT License
98 stars 0 forks source link

Documentation example doesn't work #3

Closed MilesMcBain closed 3 years ago

MilesMcBain commented 4 years ago

Trying to get the Manhattn example from the documentation to work. The first hurdle is that: tooltip(gender, geometry) seems not to work. It can't find "geometry". I've put it in quotes, just to get the map to build. When it does build, it displays, but if I attempt to interact with the map it crashes (white screen).

I see in the console:

vendor.js:16 This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.
b @ vendor.js:16
vendor.js:32 TypeError: Cannot read property '13432' of undefined
    at d (rdeck.js:1)
    at rdeck.js:1
    at Array.map (<anonymous>)
    at rdeck.js:1
    at Qo (vendor.js:32)
    at Ra (vendor.js:32)
    at Da (vendor.js:32)
    at gs (vendor.js:32)
    at ul (vendor.js:32)
    at sl (vendor.js:32)
ts @ vendor.js:32
vendor.js:32 Uncaught TypeError: Cannot read property '13432' of undefined
    at d (rdeck.js:1)
    at rdeck.js:1
    at Array.map (<anonymous>)
    at rdeck.js:1
    at Qo (vendor.js:32)
    at Ra (vendor.js:32)
    at Da (vendor.js:32)
    at gs (vendor.js:32)
    at ul (vendor.js:32)
    at sl (vendor.js:32)

code:

library(sf)
library(jsonlite)
library(rdeck)

scatterplot_data <- read_json(
  "https://raw.githubusercontent.com/uber-common/deck.gl-data/master/examples/scatterplot/manhattan.json"
) %>%
lapply(unlist) %>%
do.call(rbind, .) %>%
as_tibble() %>%
setNames(c("lon", "lat", "gender")) %>%
st_as_sf(coords = c("lon", "lat"), crs = 4326)

rdeck(
  picking_radius = 5,
  initial_view_state = view_state(
    center = c(-74, 40.76),
    zoom = 11
  )
) %>%
add_scatterplot_layer(
  data = scatterplot_data,
  radius_scale = 10,
  radius_min_pixels = 0.5,
  get_fill_color = ~ gender == 1 ? c(0, 128, 255):c(255, 0, 128),
  pickable = TRUE,
  tooltip = "tooltip(gender, geometry)"
)
anthonynorth commented 3 years ago

Closed in v0.3