library(mapgl)
library(deckglgeoarrow)
library(wk)
style_openfreemap = 'https://tiles.openfreemap.org/styles/liberty'
n = 1e3
pts = data.frame(
id = 1:n
, geometry = xy(
x = runif(n, -180, 180)
, y = runif(n, -90, 90)
, crs = 4326
)
)
pts$radius = sample.int(15, nrow(pts), replace = TRUE)
pts$fillColor = sample(hcl.colors(n, alpha = sample(seq(0, 1, length.out = n))))
pts$lineWidth = sample.int(5, nrow(pts), replace = TRUE)
pts$lineColor = sample(
hcl.colors(n, alpha = sample(seq(0, 1, length.out = n)), palette = "inferno")
)
maplibre(style = style_openfreemap) |>
addGeoArrowScatterplotLayer(
data = pts
, layer_id = "scatter"
, geom_column_name = "geometry"
, render_options = renderOptions(
beforeId = "water"
)
, data_accessors = dataAccessors(
getRadius = "radius"
, getFillColor = "fillColor"
, getLineWidth = "lineWidth"
, getLineColor = "lineColor"
)
, popup = TRUE
, popup_options = popupOptions(
anchor = "bottom-right"
)
, tooltip = "id"
, tooltip_options = tooltipOptions(
anchor = "top-left"
, closeOnMove = TRUE
)
) |>
add_navigation_control(visualize_pitch = TRUE) |>
set_view(c(0, 0), 2) |>
add_globe_control() |>
add_layers_control(
layers = list("Scatter Layer" = generateDeckglLayerId(
layer_id = "scatter", beforeId = "water")
)
)