diff --git a/DESCRIPTION b/DESCRIPTION index 1a46d4e..945ec1f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -27,3 +27,4 @@ Suggests: testthat (>= 3.0.0) Config/testthat/edition: 3 VignetteBuilder: knitr +Roxygen: list(markdown = TRUE) diff --git a/R/add_control.R b/R/add_control.R index 58d7723..3fa2948 100644 --- a/R/add_control.R +++ b/R/add_control.R @@ -1,9 +1,10 @@ #' Title #' -#' @param map -#' @param control_name -#' -#' @return +#' @param .map A [maplibre()] HTML widget +#' @param control_name The name of the control +#' @param control_position The position of the control. +#' @param ... Control options depending on the type of control. +#' @returns The updated [maplibre()] HTML widget #' @export #' #' @examples diff --git a/R/layer.R b/R/layer.R index e8af336..742a958 100644 --- a/R/layer.R +++ b/R/layer.R @@ -10,16 +10,16 @@ #' #' @export Layer <- function(type, id, source = NULL, paint = NULL, layout = NULL, ...) { - if(!is.element(type, LayerType)){ + if (!is.element(type, LayerType)) { stop( - glue::glue("type needs to be one of ", - glue::glue_collapse(unlist(maplibre::LayerType), sep = " "), - "\nSee ?maplibre::LayerType for more information." + glue::glue( + "type needs to be one of ", + glue::glue_collapse(unlist(maplibre::LayerType), sep = " "), + "\nSee ?maplibre::LayerType for more information." ) ) } - types <- list(type = is.character, id = is.character, - source = function(x) {is.list(x) | is.character(x)}, paint = is.list, layout = is.list) + c(rdantic( list( type = type, @@ -27,7 +27,7 @@ Layer <- function(type, id, source = NULL, paint = NULL, layout = NULL, ...) { source = source, paint = paint, layout = layout - ), types + ), TYPES_LAYER ), ...) |> purrr::compact() |> set_maplibre_class("MapLibreLayer") @@ -63,8 +63,8 @@ LayerType <- list( ) #' Add a layer to map #' -#' @param .map -#' @param layer +#' @inherit add_control params return +#' @param layer A [Layer()] object #' #' @example examples/layers.R #' @export diff --git a/R/maplibre.R b/R/maplibre.R index bdd287f..f655480 100644 --- a/R/maplibre.R +++ b/R/maplibre.R @@ -1,7 +1,10 @@ #' Create a Map Object for MapLibre GL #' #' -#' +#' @param map_options [mapOptions()] +#' @param width,height The width and the height of the widget. +#' @param elementId The unique ID of the widgets's HTML element. +#' @param ... Further map options. #' @import htmlwidgets #' #' @export diff --git a/R/types.R b/R/types.R index 4865ab5..9c5deec 100644 --- a/R/types.R +++ b/R/types.R @@ -4,3 +4,13 @@ TYPES_BASEMAP_STYLE <- list( sources = is.list, layers = is.list ) + +TYPES_LAYER <- list( + type = is.character, + id = is.character, + source = function(x) { + is.list(x) | is.character(x) + }, + paint = is.list, + layout = is.list +) diff --git a/man/Layer.Rd b/man/Layer.Rd index 0402319..8d58140 100644 --- a/man/Layer.Rd +++ b/man/Layer.Rd @@ -9,7 +9,7 @@ Layer(type, id, source = NULL, paint = NULL, layout = NULL, ...) \arguments{ \item{type}{The type of the layer.} -\item{id}{The unique ID of the layer. Defaults to `as.character(uuid::UUIDgenerate())`} +\item{id}{The unique ID of the layer. Defaults to \code{as.character(uuid::UUIDgenerate())}} \item{source}{The name (unique ID) of a source or a source object to be used for the layer.} diff --git a/man/LayerType.Rd b/man/LayerType.Rd index 03743af..2f11026 100644 --- a/man/LayerType.Rd +++ b/man/LayerType.Rd @@ -16,15 +16,15 @@ Rendering types of layers \details{ Rendering types of layers \itemize{ - \item \strong{CIRCLE}: A filled circle. - \item \strong{FILL}: A filled polygon with an optional stroked border. - \item \strong{FILL_EXTRUSION}: An extruded polygon. - \item \strong{LINE}: A stroked line. - \item \strong{SYMBOL}: An icon or a text label. - \item \strong{RASTER}: Raster map textures such as satellite imagery. - \item \strong{HEATMAP}: A heatmap. - \item \strong{HILLSHADE}: A Client-side hillshading visualization based on DEM data. - \item \strong{BACKGROUND}: A background color or pattern. +\item \strong{CIRCLE}: A filled circle. +\item \strong{FILL}: A filled polygon with an optional stroked border. +\item \strong{FILL_EXTRUSION}: An extruded polygon. +\item \strong{LINE}: A stroked line. +\item \strong{SYMBOL}: An icon or a text label. +\item \strong{RASTER}: Raster map textures such as satellite imagery. +\item \strong{HEATMAP}: A heatmap. +\item \strong{HILLSHADE}: A Client-side hillshading visualization based on DEM data. +\item \strong{BACKGROUND}: A background color or pattern. } } \keyword{datasets} diff --git a/man/add_control.Rd b/man/add_control.Rd index a39b3c15..ed73066 100644 --- a/man/add_control.Rd +++ b/man/add_control.Rd @@ -13,7 +13,16 @@ add_control( ) } \arguments{ -\item{control_name}{} +\item{.map}{A \code{\link[=maplibre]{maplibre()}} HTML widget} + +\item{control_name}{The name of the control} + +\item{control_position}{The position of the control.} + +\item{...}{Control options depending on the type of control.} +} +\value{ +The updated \code{\link[=maplibre]{maplibre()}} HTML widget } \description{ Title diff --git a/man/add_layer.Rd b/man/add_layer.Rd index cf56202..1492097 100644 --- a/man/add_layer.Rd +++ b/man/add_layer.Rd @@ -7,7 +7,12 @@ add_layer(.map, layer) } \arguments{ -\item{layer}{} +\item{.map}{A \code{\link[=maplibre]{maplibre()}} HTML widget} + +\item{layer}{A \code{\link[=Layer]{Layer()}} object} +} +\value{ +The updated \code{\link[=maplibre]{maplibre()}} HTML widget } \description{ Add a layer to map diff --git a/man/maplibre.Rd b/man/maplibre.Rd index e016c35..624c506 100644 --- a/man/maplibre.Rd +++ b/man/maplibre.Rd @@ -12,6 +12,15 @@ maplibre( ... ) } +\arguments{ +\item{map_options}{\code{\link[=mapOptions]{mapOptions()}}} + +\item{width, height}{The width and the height of the widget.} + +\item{elementId}{The unique ID of the widgets's HTML element.} + +\item{...}{Further map options.} +} \description{ Create a Map Object for MapLibre GL }