Skip to content

Commit

Permalink
add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
trafficonese committed Sep 1, 2024
1 parent 81a1709 commit 633af42
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 20 deletions.
10 changes: 4 additions & 6 deletions R/heightgraph.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,33 +40,31 @@ heightgraphDependency <- function() {
#' @family Heightgraph Functions
#' @inherit leaflet::addGeoJSON return
#' @export
#' @examples \dontrun{
#' @examples
#' library(leaflet)
#' library(leaflet.extras2)
#' library(sf)
#'
#' data <- st_cast(st_as_sf(leaflet::atlStorms2005[4,]), "LINESTRING")
#' data <- st_transform(data, 4326)
#' data <- data.frame(st_coordinates(data))
#' data$elev <- runif(nrow(data), 10, 500)
#' data$elev <- round(runif(nrow(data), 10, 500), 2)
#' data$L1 <- NULL
#' L1 <- round(seq.int(1, 4, length.out = nrow(data)))
#' data <- st_as_sf(st_sfc(lapply(split(data, L1), sfg_linestring)))
#' data <- st_as_sf(st_sfc(lapply(split(data, L1), function(x) {
#' st_linestring(as.matrix(x))
#' st_linestring(as.matrix(x))
#' })))
#' data$steepness <- 1:nrow(data)
#' data$suitability <- nrow(data):1
#' data$popup <- apply(data, 1, function(x) {
#' sprintf("Steepness: %s<br>Suitability: %s", x$steepness, x$suitability)
#' sprintf("Steepness: %s<br>Suitability: %s", x$steepness, x$suitability)
#' })
#'
#' leaflet() %>%
#' addTiles(group = "base") %>%
#' addHeightgraph(color = "red", columns = c("steepness", "suitability"),
#' opacity = 1, data = data, group = "heightgraph",
#' options = heightgraphOptions(width = 400))
#' }
addHeightgraph <- function(
map, data = NULL, columns = NULL, layerId = NULL, group = NULL,
color = "#03F", weight = 5, opacity = 0.5,
Expand Down
11 changes: 11 additions & 0 deletions R/labelgun.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ labelgunDependency <- function() {
#' @references \url{https://github.com/Geovation/labelgun}
#'
#' @name addLabelgun
#' @examples
#' library(leaflet)
#' library(leaflet.extras2)
#'
#' leaflet() %>%
#' addTiles() %>%
#' addMarkers(data = breweries91,
#' label = ~brewery,
#' group = "markers",
#' labelOptions = labelOptions(permanent = TRUE)) %>%
#' addLabelgun("markers", 1)
addLabelgun <- function(map, group=NULL, weight=NULL, entries=NULL) {
stopifnot("The group argument is NULL. Please define a valid group." = !is.null(group))
map$dependencies <- c(map$dependencies, labelgunDependency())
Expand Down
3 changes: 1 addition & 2 deletions R/movingmarker.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ leafletAwesomeMarkersDependencies1 <- function() {
#' @references \url{https://github.com/ewoken/Leaflet.MovingMarker}
#' @inherit leaflet::addMarkers return
#' @export
#' @examples \dontrun{
#' @examples
#' library(sf)
#' library(leaflet)
#' library(leaflet.extras2)
Expand All @@ -55,7 +55,6 @@ leafletAwesomeMarkersDependencies1 <- function() {
#' movingOptions = movingMarkerOptions(autostart = TRUE, loop = TRUE),
#' label="I am a pirate!",
#' popup="Arrr")
#' }
addMovingMarker = function(
map, lng = NULL, lat = NULL, layerId = NULL, group = NULL,
duration = 2000,
Expand Down
3 changes: 1 addition & 2 deletions R/timeslider.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ timesliderDependencies <- function() {
#' @export
#' @inheritParams leaflet::addCircleMarkers
#' @inherit leaflet::addMarkers return
#' @examples \dontrun{
#' @examples
#' library(leaflet)
#' library(leaflet.extras2)
#' library(sf)
Expand All @@ -47,7 +47,6 @@ timesliderDependencies <- function() {
#' timeAttribute = "time",
#' range = TRUE)) %>%
#' setView(-72, 22, 4)
#' }
addTimeslider <- function(map, data, radius = 10,
stroke = TRUE, color = "#03F",
weight = 5, opacity = 0.5, fill = TRUE, fillColor = color,
Expand Down
9 changes: 3 additions & 6 deletions man/addHeightgraph.Rd

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

12 changes: 12 additions & 0 deletions man/addLabelgun.Rd

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

2 changes: 0 additions & 2 deletions man/addMovingMarker.Rd

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

2 changes: 0 additions & 2 deletions man/addTimeslider.Rd

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

0 comments on commit 633af42

Please sign in to comment.