-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stefan Kuethe
committed
Oct 4, 2024
1 parent
be2251a
commit e3d219b
Showing
8 changed files
with
161 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#' Add `deck.gl` layers to the map | ||
#' @inherit add_control params return | ||
#' @param layers A list of `deck.gl` layers. | ||
#' @param tooltip Either a single mustache template string applied to all layers | ||
#' or a dictionary where keys are layer ids and values are mustache template strings. | ||
#' @example examples/deck-gl.R | ||
#' @export | ||
add_deck_layers <- function(.map, layers, tooltip = NULL) { | ||
add_call(.map, "addDeckOverlay", layers, tooltip) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
DECK_GL_VERSION <- "9.0.16" | ||
|
||
dependency_deck_gl <- htmltools::htmlDependency( | ||
name = "deck.gl", | ||
version = DECK_GL_VERSION, | ||
src = list( | ||
href = glue::glue("https://unpkg.com/deck.gl@{DECK_GL_VERSION}") | ||
), | ||
script = "dist.min.js", | ||
all_files = FALSE | ||
) | ||
|
||
dependency_deck_gl_json <- htmltools::htmlDependency( | ||
name = "deck.gl.json", | ||
version = DECK_GL_VERSION, | ||
src = list( | ||
href = glue::glue("https://unpkg.com/@deck.gl/json@{DECK_GL_VERSION}") | ||
), | ||
script = "dist.min.js", | ||
all_files = FALSE | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
deck_grid_layer <- list( | ||
"@@type" = "GridLayer", | ||
id = "GridLayer", | ||
data = "https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/sf-bike-parking.json", | ||
extruded = TRUE, | ||
getPosition = "@@=COORDINATES", | ||
getColorWeight = "@@=SPACES", | ||
getElevationWeight = "@@=SPACES", | ||
elevationScale = 4, | ||
cellSize = 200, | ||
pickable = TRUE | ||
) | ||
|
||
setup <- mapOptions( | ||
center = list(-122.4, 37.74), | ||
zoom = 12, | ||
pitch = 40, | ||
hash = TRUE | ||
) | ||
|
||
maplibre(setup, deck = TRUE) |> | ||
add_deck_layers(list(deck_grid_layer)) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
title: "deck.gl integration" | ||
--- | ||
|
||
```{r, include = FALSE} | ||
knitr::opts_chunk$set( | ||
collapse = TRUE, | ||
comment = "#>" | ||
) | ||
``` | ||
|
||
```{r setup} | ||
library(maplibre) | ||
``` | ||
|
||
```{r} | ||
deck_grid_layer <- list( | ||
"@@type" = "GridLayer", | ||
id = "GridLayer", | ||
data = "https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/sf-bike-parking.json", | ||
extruded = TRUE, | ||
getPosition = "@@=COORDINATES", | ||
getColorWeight = "@@=SPACES", | ||
getElevationWeight = "@@=SPACES", | ||
elevationScale = 4, | ||
cellSize = 200, | ||
pickable = TRUE | ||
) | ||
setup <- mapOptions( | ||
center = list(-122.4, 37.74), | ||
zoom = 12, | ||
pitch = 40, | ||
hash = TRUE | ||
) | ||
maplibre(setup, deck = TRUE) |> | ||
add_control("NavigationControl") |> | ||
add_deck_layers( | ||
list(deck_grid_layer), | ||
tooltip = "Number of points: {{ count }}" | ||
) | ||
``` |