Skip to content

Commit

Permalink
more manual tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Apr 2, 2024
1 parent 9d0f4e4 commit b1a698c
Show file tree
Hide file tree
Showing 17 changed files with 96 additions and 69 deletions.
14 changes: 6 additions & 8 deletions R/colors.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' Conveniently maps data values (numeric or factor/character) to colors
#' according to a given palette, which can be provided in a variety of formats.
#'
#' `colorNumeric` is a simple linear mapping from continuous numeric data
#' `colorNumeric()` is a simple linear mapping from continuous numeric data
#' to an interpolated palette.
#'
#' @param palette The colors or color function that values will be mapped to
Expand Down Expand Up @@ -93,8 +93,8 @@ getBins <- function(domain, x, bins, pretty) {
}
}

#' @details `colorBin` also maps continuous numeric data, but performs
#' binning based on value (see the [base::cut()] function). `colorBin`
#' @details `colorBin()` also maps continuous numeric data, but performs
#' binning based on value (see the [base::cut()] function). `colorBin()`
#' defaults for the [base::cut()] function are `include.lowest
#' = TRUE` and `right = FALSE`.
#' @param bins Either a numeric vector of two or more unique cut points or a
Expand Down Expand Up @@ -136,12 +136,10 @@ colorBin <- function(palette, domain, bins = 7, pretty = TRUE,
})
}

#' @details `colorQuantile()` similarly bins numeric data, but via the
#' [stats::quantile()] function.
#' @details `colorQuantile()` similarly bins numeric data, but via [stats::quantile()].
#' @param n Number of equal-size quantiles desired. For more precise control,
#' use the `probs` argument instead.
#' @param probs See [stats::quantile()]. If provided, the `n`
#' argument is ignored.
#' use `probs` instead.
#' @param probs See [stats::quantile()]. If provided, `n` is ignored.
#' @rdname colorNumeric
#' @export
colorQuantile <- function(palette, domain, n = 4,
Expand Down
4 changes: 2 additions & 2 deletions R/controls.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' @param html the content of the control. May be provided as string or as HTML
#' generated with Shiny/htmltools tags
#' @param position position of control: "topleft", "topright", "bottomleft", or
#' "bottomright"
#' @param position position of control: `"topleft"`, `"topright"`,
#' `"bottomleft"`, or `"bottomright"`.
#' @param className extra CSS classes to append to the control, space separated
#'
#' @describeIn map-layers Add arbitrary HTML controls to the map
Expand Down
10 changes: 5 additions & 5 deletions R/layers.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,13 @@ epsg3857 <- "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y
#' a `RasterLayer` you can use [raster::sampleRegular()] as in
#' `sampleRegular(x, 100000, asRaster=TRUE)`.
#'
#' By default, the `addRasterImage` function will project the raster data
#' By default, `addRasterImage()` will project the raster data
#' `x` to the Pseudo-Mercator projection (EPSG:3857). This can be a
#' time-consuming operation for even moderately sized rasters; although it is much
#' faster for SpatRasters than for RasterLayers.
#' If you are repeatedly adding a particular raster to your Leaflet
#' maps, you can perform the projection ahead of time using
#' `projectRasterForLeaflet()`, and call `addRasterImage` with
#' `projectRasterForLeaflet()`, and call `addRasterImage()` with
#' `project = FALSE`.
#'
#' @param map a map widget object
Expand Down Expand Up @@ -1175,7 +1175,7 @@ b64EncodePackedIcons <- function(packedIcons) {
}

#' @param interactive whether the element emits mouse events
#' @param clickable DEPRECATED! Use the `interactive` option.
#' @param clickable DEPRECATED! Use the `interactive` argument.
#' @param
#' draggable,keyboard,title,alt,zIndexOffset,riseOnHover,riseOffset
#' marker options; see <https://web.archive.org/web/20220702182250/https://leafletjs.com/reference-1.3.4.html#marker-option>
Expand Down Expand Up @@ -1597,8 +1597,8 @@ clearGeoJSON <- function(map) {
#' most commonly used for mostly-opaque tile layers.
#' @param overlayGroups character vector where each element is the name of a
#' group. The user can turn each overlay group on or off independently.
#' @param position position of control: "topleft", "topright", "bottomleft", or
#' "bottomright"
#' @param position position of control: `"topleft"`, `"topright"`,
#' `"bottomleft"`, or `"bottomright"`.
#' @param options a list of additional options, intended to be provided by
#' a call to `layersControlOptions()`
#' @template data-getMapData
Expand Down
11 changes: 6 additions & 5 deletions R/leaflet.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#' Leaflet sizing policy
#'
#' Sizing policy used withing leaflet htmlwidgets.
#' All arguments are passed directly to [htmlwidgets::sizingPolicy()]
#'
#' @export
#' @param defaultWidth defaults to `"100%"` of the available width
#' @param defaultHeight defaults to 400px tall
#' @param padding defaults to 0px
#' @param browser.fill defaults to `TRUE`
#' @param ... all other arguments supplied to [htmlwidgets::sizingPolicy()]
#' @inheritDotParams htmlwidgets::sizingPolicy
#' @return An `htmlwidgets::sizingPolicy` object
leafletSizingPolicy <- function(
defaultWidth = "100%",
Expand Down Expand Up @@ -140,11 +139,13 @@ mapOptions <- function(map, zoomToLimits = c("always", "first", "never")) {
}

#' Options for Map creation
#' @param minZoom Minimum zoom level of the map. Overrides any minZoom set on map layers.
#' @param maxZoom Maximum zoom level of the map. This overrides any maxZoom set on map layers.
#' @param minZoom Minimum zoom level of the map. Overrides any `minZoom` set on map layers.
#' @param maxZoom Maximum zoom level of the map. This overrides any `maxZoom` set on map layers.
#' @param crs Coordinate Reference System to use. Don't change this if you're not sure what it means.
#' @seealso [leafletCRS()] for creating a custom CRS.
#' @param worldCopyJump With this option enabled, the map tracks when you pan to another "copy" of the world and seamlessly jumps to the original one so that all overlays like markers and vector layers are still visible.
#' @param worldCopyJump With this option enabled, the map tracks when you pan
#' to another "copy" of the world and seamlessly jumps to the original
#' one so that all overlays like markers and vector layers are still visible.
#' @param preferCanvas Whether leaflet.js Paths should be rendered on a Canvas renderer.
#' @param ... other options used for leaflet.js map creation.
#' @describeIn leaflet Options for map creation
Expand Down
9 changes: 4 additions & 5 deletions R/plugin-awesomeMarkers.R
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ makeAwesomeIcon <- function(
#' An icon can be represented as a list of the form `list(icon, library,
#' ...)`. This function is vectorized over its arguments to create a list of
#' icon data. Shorter argument values will be recycled. `NULL` values for
#' these arguments will be ignored.
#' these arguments will be ignored.
#' @seealso <https://github.com/lennardv2/Leaflet.awesome-markers>
#' @param icon Name of the icon
#' @param library Which icon library. Default `"glyphicon"`, other possible
Expand All @@ -175,15 +175,14 @@ makeAwesomeIcon <- function(
#' `"cadetblue"`, `"white"`, `"gray"`, `"lightgray"`, `"black"`
#' @param iconColor The color to use for the icon itself. Use any CSS-valid
#' color (hex, rgba, etc.) or a named web color.
#' @param spin If `TRUE`, make the icon spin (only works when `library
#' = "fa"`)
#' @param spin If `TRUE`, make the icon spin (only works when `library = "fa"`)
#' @param extraClasses Additional css classes to include on the icon.
#' @return A list of awesome-icon data that can be passed to the `icon`
#' @param squareMarker Whether to use a square marker.
#' @param iconRotate Rotate the icon by a given angle.
#' @param fontFamily Used when `text` option is specified.
#' @param text Use this text string instead of an icon.
#' argument of [addAwesomeMarkers()].
#' @param text Use this text string instead of an icon. Argument of
#' [addAwesomeMarkers()].
#' @export
awesomeIcons <- function(
icon = "home",
Expand Down
16 changes: 6 additions & 10 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@

#' Extension points for plugins
#'
#' @param map a map object, as returned from [leaflet()] or
#' [leafletProxy()]
#' @param map a map object, as returned from [leaflet()] or [leafletProxy()]
#' @param funcName the name of the function that the user called that caused
#' this `dispatch` call; for error message purposes
#' @param leaflet an action to be performed if the map is from
#' [leaflet()]
#' @param leaflet_proxy an action to be performed if the map is from
#' [leafletProxy()]
#' @param leaflet an action to be performed if the map is from [leaflet()]
#' @param leaflet_proxy an action to be performed if the map is from [leafletProxy()].
#'
#' @return `dispatch()` returns the value of `leaflet` or
#' `leaflet_proxy()`, or an error. `invokeMethod()` returns the
Expand Down Expand Up @@ -44,8 +41,7 @@ filterNULL <- function(x) {
x[!unlist(lapply(x, is.null))]
}

#' @param data a data object that will be used when evaluating formulas in
#' `...`
#' @param data a data object that will be used when evaluating formulas in `...`
#' @param method the name of the JavaScript method to invoke
#' @param ... unnamed arguments to be passed to the JavaScript method
#' @rdname dispatch
Expand Down Expand Up @@ -83,7 +79,7 @@ invokeMethod <- function(map, data, method, ...) {
#' Creates a map-like object that can be used to customize and control a map
#' that has already been rendered. For use in Shiny apps and Shiny docs only.
#'
#' Normally, you create a Leaflet map using the [leaflet()] function.
#' Normally, you create a Leaflet map using [leaflet()].
#' This creates an in-memory representation of a map that you can customize
#' using functions like [addPolygons()] and [setView()].
#' Such a map can be printed at the R console, included in an R Markdown
Expand All @@ -94,7 +90,7 @@ invokeMethod <- function(map, data, method, ...) {
#' map is long gone, and the user's web browser has already realized the Leaflet
#' map instance.
#'
#' This is where `leafletProxy` comes in. It returns an object that can
#' This is where `leafletProxy()` comes in. It returns an object that can
#' stand in for the usual Leaflet map object. The usual map functions like
#' [addPolygons()] and [setView()] can be called, and
#' instead of customizing an in-memory representation, these commands will
Expand Down
4 changes: 2 additions & 2 deletions man/addLayersControl.Rd

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

4 changes: 2 additions & 2 deletions man/addRasterImage.Rd

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

4 changes: 2 additions & 2 deletions man/awesomeIcons.Rd

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

14 changes: 6 additions & 8 deletions man/colorNumeric.Rd

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

12 changes: 4 additions & 8 deletions man/dispatch.Rd

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

8 changes: 5 additions & 3 deletions man/leaflet.Rd

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

4 changes: 2 additions & 2 deletions man/leafletProxy.Rd

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

41 changes: 39 additions & 2 deletions man/leafletSizingPolicy.Rd

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

Loading

0 comments on commit b1a698c

Please sign in to comment.