Skip to content

Commit

Permalink
Add func to build basemap style
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Kuethe committed Oct 4, 2024
1 parent 48959ab commit 54444f1
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 38 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export(add_layer)
export(add_marker)
export(add_popup)
export(add_tooltip)
export(construct_basemap_style)
export(mapOptions)
export(maplibre)
export(maplibreOutput)
Expand Down
16 changes: 16 additions & 0 deletions R/basemaps.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#' Create a basemap style definition
#' @param sources The sources to be used for the basemap style.
#' @param layers The layers to be used for the basemap style.
#' @param name The name of the basemap style.
#' @returns list
#' @example examples/pmtiles.R
#' @export
construct_basemap_style <- function(sources, layers, name = "custom-basemap") {
basemap_style <- list(
name = name,
version = 8L,
sources = sources,
layers = layers
)
return(rdantic(basemap_style, TYPES_BASEMAP_STYLE))
}
6 changes: 6 additions & 0 deletions R/types.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TYPES_BASEMAP_STYLE <- list(
name = is.character,
version = is.integer,
sources = is.list,
layers = is.list
)
5 changes: 3 additions & 2 deletions examples/pmtiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ roads <- Layer(
paint = list("line-color" = "black"),
)

custom_basemap <- list(
name = "custom-style", version = 8, sources = sources, layers = list(landuse, roads)
custom_basemap <- construct_basemap_style(
sources,
layers = list(landuse, roads)
)

setup <- mapOptions(
Expand Down
7 changes: 2 additions & 5 deletions man/Layer.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions man/Marker.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions man/MarkerOptions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions man/add_layer.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions man/add_marker.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions man/add_popup.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions man/add_tooltip.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions man/construct_basemap_style.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/maplibre.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 54444f1

Please sign in to comment.