diff --git a/R/tangram.R b/R/tangram.R
index d8360d1..5dfcb57 100644
--- a/R/tangram.R
+++ b/R/tangram.R
@@ -57,7 +57,8 @@ tangram_deps <- function() {
#' }
addTangram <- function(map, scene = NULL, layerId = NULL, group = NULL,
options = NULL) {
- if ((is.null(scene) || !is.character(scene) || (!gsub(".*\\.", "", scene) %in% c("yaml", "zip")))) {
+ if ((is.null(scene) || !is.character(scene) ||
+ (!gsub(".*\\.", "", scene) %in% c("yaml", "zip")))) {
stop(
"The scene must point to a valid .yaml or .zip file.\n",
"See the documentation for further information."
diff --git a/R/timeslider.R b/R/timeslider.R
index 5a994f7..f68b86e 100644
--- a/R/timeslider.R
+++ b/R/timeslider.R
@@ -2,7 +2,8 @@ timesliderDependencies <- function() {
list(
htmlDependency(
"lfx-timeslider", "1.0.0",
- src = system.file("htmlwidgets/lfx-timeslider", package = "leaflet.extras2"),
+ src = system.file("htmlwidgets/lfx-timeslider",
+ package = "leaflet.extras2"),
stylesheet = "jquery-ui.css",
script = c(
"jquery-ui.min.js",
@@ -54,7 +55,8 @@ timesliderDependencies <- function() {
#' setView(-72, 22, 4)
addTimeslider <- function(map, data, radius = 10,
stroke = TRUE, color = "#03F",
- weight = 5, opacity = 0.5, fill = TRUE, fillColor = color,
+ weight = 5, opacity = 0.5, fill = TRUE,
+ fillColor = color,
fillOpacity = 0.2, dashArray = NULL,
popup = NULL, popupOptions = NULL,
label = NULL, labelOptions = NULL,
@@ -107,7 +109,8 @@ addTimeslider <- function(map, data, radius = 10,
## Add Deps and invoke Leaflet
map$dependencies <- c(map$dependencies, timesliderDependencies())
- invokeMethod(map, NULL, "addTimeslider", data, options, popupOptions, labelOptions) %>%
+ invokeMethod(map, NULL, "addTimeslider", data, options,
+ popupOptions, labelOptions) %>%
expandLimits(bbox[c(2, 4)], bbox[c(1, 3)])
}
diff --git a/R/velocity.R b/R/velocity.R
index 00a1cda..e2cce38 100644
--- a/R/velocity.R
+++ b/R/velocity.R
@@ -2,7 +2,8 @@ velocityDependencies <- function() {
list(
htmlDependency(
"lfx-velocity", "1.0.0",
- src = system.file("htmlwidgets/lfx-velocity", package = "leaflet.extras2"),
+ src = system.file("htmlwidgets/lfx-velocity",
+ package = "leaflet.extras2"),
script = c(
"leaflet-velocity.js",
"leaflet-velocity-bindings.js"
@@ -18,8 +19,8 @@ velocityDependencies <- function() {
#' \href{https://github.com/onaci/leaflet-velocity}{leaflet-velocity plugin}
#' @inheritParams leaflet::addMarkers
#' @param content the path or URL to a JSON file representing the velocity data
-#' or a data.frame which can be transformed to such a JSON file. Please see the
-#' \href{https://github.com/onaci/leaflet-velocity/tree/master/demo}{demo
+#' or a data.frame which can be transformed to such a JSON file. Please see
+#' the \href{https://github.com/onaci/leaflet-velocity/tree/master/demo}{demo
#' files} for some example data.
#' @param options List of further options. See \code{\link{velocityOptions}}
#' @export
@@ -72,7 +73,8 @@ addVelocity <- function(map, layerId = NULL, group = NULL,
#' @param velocityScale scale for wind velocity
#' @param colorScale A vector of hex colors or an RGB matrix
#' @param ... Further arguments passed to the Velocity layer and Windy.js.
-#' For more information, please visit \href{https://github.com/onaci/leaflet-velocity}{leaflet-velocity plugin}
+#' For more information, please visit
+#' \href{https://github.com/onaci/leaflet-velocity}{leaflet-velocity plugin}
#' @return A list of further options for \code{addVelocity}
#' @export
#' @family Velocity Functions
diff --git a/data-raw/data-raw.R b/data-raw/data-raw.R
index d7dc6b7..490eab6 100644
--- a/data-raw/data-raw.R
+++ b/data-raw/data-raw.R
@@ -1,4 +1,6 @@
-gibs_layerslink <- paste0(system.file("htmlwidgets/lfx-gibs", package = "leaflet.extras2"), "/gibs_layers_meta.json")
+gibs_layerslink <- paste0(
+ system.file("htmlwidgets/lfx-gibs",
+ package = "leaflet.extras2"), "/gibs_layers_meta.json")
gibs_layers <- jsonify::from_json(json = gibs_layerslink, simplify = TRUE)
gibs_layers <- data.frame(do.call(rbind, gibs_layers), stringsAsFactors = FALSE)
gibs_layers$title <- as.character(gibs_layers$title)
diff --git a/inst/examples/antpath_app.R b/inst/examples/antpath_app.R
index 19779b5..44c39bb 100644
--- a/inst/examples/antpath_app.R
+++ b/inst/examples/antpath_app.R
@@ -27,18 +27,19 @@ server <- function(input, output, session) {
label = ~sprintf("Ant-Colony of %s", district),
group = "antgroup",
color = cols,
- weight = 2 + (1:nrow(coords))/30,
+ weight = 2 + (1:nrow(coords)) / 30,
popup = ~FGN,
opacity = 1,
options = antpathOptions(
- pulseColor = colorNumeric("Reds",
+ pulseColor = colorNumeric(
+ "Reds",
domain = as.numeric(coords$FKN))(as.numeric(coords$FKN)),
delay = 4000,
paused = FALSE,
renderer= JS('L.svg({pane: "my-pane"})'),
reverse = TRUE,
dashArray = c(40, 10),
- hardwareAccelerated = T,
+ hardwareAccelerated = TRUE,
interactive = TRUE,
lineCap = "butt",
lineJoin = "butt",
diff --git a/inst/examples/arrowhead_app.R b/inst/examples/arrowhead_app.R
index 69f3d48..5731180 100644
--- a/inst/examples/arrowhead_app.R
+++ b/inst/examples/arrowhead_app.R
@@ -3,60 +3,61 @@ library(leaflet)
library(leaflet.extras2)
ui <- fluidPage(
- leafletOutput("map", height=800),
+ leafletOutput("map", height = 800),
actionButton("clear", "Clear Group"),
actionButton("remove", "Remove"),
actionButton("clearArrowhead", "Remove Arrowheads by group"),
- actionButton("removeArrowhead", "Remove Arrowheads by layerId's")
+ actionButton("removeArrowhead", "Remove Arrowheads by layerIds")
)
server <- function(input, output, session) {
output$map <- renderLeaflet({
leaflet() %>%
addTiles() %>%
- addLayersControl(overlayGroups = c("blue","red")) %>%
+ addLayersControl(overlayGroups = c("blue", "red")) %>%
## Blue #############
- addArrowhead(data = atlStorms2005[1:10,], color="blue",
- group="blue",
+ addArrowhead(data = atlStorms2005[1:10,], color = "blue",
+ group = "blue",
options = arrowheadOptions(
yawn = 60,
- size = '7%',
- frequency = 'endonly',
+ size = "7%",
+ frequency = "endonly",
fill = TRUE,
- opacity=0.5, stroke=FALSE, fillOpacity=0.4,
+ opacity = 0.5, stroke = FALSE, fillOpacity = 0.4,
proportionalToTotal = TRUE,
offsets = NULL,
perArrowheadOptions = NULL)) %>%
## Red #############
- addArrowhead(data = atlStorms2005[11:20,], color = "red",
+ addArrowhead(data = atlStorms2005[11:20, ], color = "red",
group = "red",
- layerId = paste0("inp",1:10),
+ layerId = paste0("inp", 1:10),
options = arrowheadOptions(
yawn = 90,
- size = '10px',
- frequency = 'allvertices',
+ size = "10px",
+ frequency = "allvertices",
fill = TRUE,
offsets = NULL,
perArrowheadOptions = NULL)) %>%
## Green #############
- addArrowhead(data = atlStorms2005[21,], color = "green", group="green",
+ addArrowhead(data = atlStorms2005[21, ], color = "green",
+ group = "green",
options = arrowheadOptions(
- size = '10px',
- frequency = '50px',
- offsets = list('start' = '100m', 'end' = '15px'),
+ size = "10px",
+ frequency = "50px",
+ offsets = list("start" = "100m", "end" = "15px"),
fill = TRUE)) %>%
## Yellow #############
- addArrowhead(data = atlStorms2005[22,], color = "yellow",
+ addArrowhead(data = atlStorms2005[22, ], color = "yellow",
options = arrowheadOptions(
size = "25000m",
- frequency = '200000m',
+ frequency = "200000m",
fill = TRUE)) %>%
## Purple #############
- addArrowhead(data = atlStorms2005[24,], color = "purple",
+ addArrowhead(data = atlStorms2005[24, ], color = "purple",
options = arrowheadOptions(
- opacity=1, fillOpacity=1,
+ opacity = 1, fillOpacity = 1,
frequency = "30px",
- size= "20px", fill=TRUE,
+ size = "20px", fill = TRUE,
perArrowheadOptions = leaflet::JS("(i) => ({
color: `rgba(150, 20, ${0 + 20 * i}, 1)`,
})")))
@@ -75,7 +76,7 @@ server <- function(input, output, session) {
})
observeEvent(input$removeArrowhead, {
leafletProxy("map") %>%
- removeArrowhead(paste0("inp",1:5))
+ removeArrowhead(paste0("inp", 1:5))
})
}
shinyApp(ui, server)
diff --git a/inst/examples/buildings_app.R b/inst/examples/buildings_app.R
index 9458633..107ab10 100644
--- a/inst/examples/buildings_app.R
+++ b/inst/examples/buildings_app.R
@@ -5,21 +5,21 @@ library(sf)
library(leaflet.extras2)
options("shiny.autoreload" = TRUE)
-cols <- c("green","orange","red","pink","yellow","blue","lightblue")
-darkcols <- c("lightgray","gray","#c49071","#876302","#443408")
+cols <- c("green", "orange", "red", "pink", "yellow", "blue", "lightblue")
+darkcols <- c("lightgray", "gray", "#c49071", "#876302", "#443408")
## Custom GeoJSON ###########
## Get a Sample Building Dataset from
# https://hub.arcgis.com/datasets/IthacaNY::buildings/explore?location=42.432557%2C-76.486649%2C13.42
geojson <- yyjsonr::read_geojson_file("Buildings_mini.geojson")
-geojson$height= sample(seq(50,100,5), nrow(geojson), replace = TRUE)
-geojson$color= sample(cols, nrow(geojson), replace = TRUE)
-geojson$wallColor= sample(cols, nrow(geojson), replace = TRUE)
-geojson$roofColor= sample(darkcols, nrow(geojson), replace = TRUE)
-geojson$shape= sample(c("cylinder","sphere",""), nrow(geojson), replace = TRUE)
-geojson$roofHeight= geojson$height + sample(seq(1,10,1), nrow(geojson), replace = TRUE)
-geojson$roofShape= sample(c("dome","pyramidal", "butterfly","gabled","half-hipped",
- "gambrel","onion"), nrow(geojson), replace = TRUE)
+geojson$height <- sample(seq(50, 100, 5), nrow(geojson), replace = TRUE)
+geojson$color <- sample(cols, nrow(geojson), replace = TRUE)
+geojson$wallColor <- sample(cols, nrow(geojson), replace = TRUE)
+geojson$roofColor <- sample(darkcols, nrow(geojson), replace = TRUE)
+geojson$shape <- sample(c("cylinder", "sphere", ""), nrow(geojson), replace = TRUE)
+geojson$roofHeight <- geojson$height + sample(seq(1, 10, 1), nrow(geojson), replace = TRUE)
+geojson$roofShape <- sample(c("dome", "pyramidal", "butterfly", "gabled", "half-hipped",
+ "gambrel", "onion"), nrow(geojson), replace = TRUE)
geojson <- yyjsonr::write_geojson_str(geojson)
class(geojson) <- "json"
@@ -32,7 +32,7 @@ ui <- fluidPage(
, selectInput("src", label = "Data Source", choices = c("OSM", "GeoJSON"))
, h4("Change the Date and Time-Slider to Adapt the Shadow")
, dateInput("date", "Date")
- , sliderInput("time", "Time", 7, max =20, value = 11, step = 1)
+ , sliderInput("time", "Time", 7, max = 20, value = 11, step = 1)
, h4("Change the Style and the Data")
, actionButton("style", "Update Style")
, actionButton("data", "Update Data")
@@ -47,7 +47,7 @@ ui <- fluidPage(
## SERVER ###########
server <- function(input, output, session) {
output$map <- renderLeaflet({
- m <- leaflet() %>%
+ m <- leaflet() %>%
addProviderTiles("CartoDB")
if (input$src == "OSM") {
@@ -78,20 +78,22 @@ server <- function(input, output, session) {
})
observeEvent(input$style, {
leafletProxy("map") %>%
- setBuildingStyle(style = list(color = sample(cols, 1),
- wallColor = sample(cols, 1),
- roofColor = sample(cols, 1),
- roofShape = sample(c("dome","pyramidal", "butterfly","gabled","half-hipped",
- "gambrel","onion"), 1),
- shadows = sample(c(TRUE, FALSE), 1)))
+ setBuildingStyle(style = list(
+ color = sample(cols, 1),
+ wallColor = sample(cols, 1),
+ roofColor = sample(cols, 1),
+ roofShape = sample(c("dome", "pyramidal", "butterfly",
+ "gabled", "half-hipped",
+ "gambrel", "onion"), 1),
+ shadows = sample(c(TRUE, FALSE), 1)))
})
observeEvent(input$data, {
geojson <- yyjsonr::read_geojson_file("Buildings_mini.geojson")
- filtered <- geojson[sample(1:nrow(geojson), 10, F),]
- filtered$height= sample(seq(50,140,5), nrow(filtered), replace = TRUE)
- filtered$color= sample(cols, nrow(filtered), replace = TRUE)
- filtered$wallColor= sample(cols, nrow(filtered), replace = TRUE)
- filtered$roofColor= sample(cols, nrow(filtered), replace = TRUE)
+ filtered <- geojson[sample(1:nrow(geojson), 10, FALSE),]
+ filtered$height <- sample(seq(50,140,5), nrow(filtered), replace = TRUE)
+ filtered$color <- sample(cols, nrow(filtered), replace = TRUE)
+ filtered$wallColor <- sample(cols, nrow(filtered), replace = TRUE)
+ filtered$roofColor <- sample(cols, nrow(filtered), replace = TRUE)
filtered <- yyjsonr::write_geojson_str(filtered)
class(filtered) <- "json"
diff --git a/inst/examples/clusterCharts_app.R b/inst/examples/clusterCharts_app.R
index 292a933..381005e 100644
--- a/inst/examples/clusterCharts_app.R
+++ b/inst/examples/clusterCharts_app.R
@@ -6,30 +6,22 @@ library(leaflet.extras2)
options("shiny.autoreload" = TRUE)
-# shipIcon <- leaflet::makeIcon(
-# iconUrl = "./icons/Icon5.svg"
-# ,className = "lsaicons"
-# ,iconWidth = 24, iconHeight = 24, iconAnchorX = 0, iconAnchorY = 0
-# )
shipIcon <- iconList(
"Schwer" = makeIcon("./icons/Icon5.svg", iconWidth = 32, iconHeight = 32),
"Mäßig" = makeIcon("./icons/Icon8.svg", iconWidth = 32, iconHeight = 32),
"Leicht" = makeIcon("./icons/Icon25.svg", iconWidth = 32, iconHeight = 32),
"kein Schaden" = makeIcon("./icons/Icon29.svg", iconWidth = 32, iconHeight = 32)
)
-# shipIcon <- makeIcon(
-# iconUrl = "https://cdn-icons-png.flaticon.com/512/1355/1355883.png",
-# iconWidth = 40, iconHeight = 50,
-# iconAnchorX = 0, iconAnchorY = 0
-# )
data <- sf::st_as_sf(breweries91)
-data$categoryfields <- sample(c("Schwer", "Mäßig", "Leicht", "kein Schaden"), size = nrow(data), replace = TRUE)
+data$categoryfields <- sample(c("Schwer", "Mäßig", "Leicht", "kein Schaden"),
+ size = nrow(data), replace = TRUE)
data$label <- paste0(data$brewery, "
", data$address)
data$id <- paste0("ID", seq.int(nrow(data)))
data$popup <- paste0("
", data$brewery, "
", data$address, "
")
data$web <- gsub(">(.*?)<", ">LINK<", data$web)
-data$web <- ifelse(is.na(data$web), "", paste0("", data$web, "
"))
+data$web <- ifelse(is.na(data$web), "",
+ paste0("", data$web, "
"))
data$tosum <- sample(1:100, nrow(data), replace = TRUE)
ui <- fluidPage(
@@ -50,14 +42,15 @@ ui <- fluidPage(
}")),
div(class="inputdiv",
div(class="inputs",
- selectInput("type", "Plot type", choices = c("bar","horizontal", "pie"), selected = "pie"),
+ selectInput("type", "Plot type", choices = c("bar","horizontal", "pie"),
+ selected = "pie"),
numericInput("stroke", "strokeWidth", 1, 1, 10),
numericInput("rmax", "MaxRadius", 50, 1, 150),
numericInput("innerRadius", "InnerRadius", 10, 1, 100),
numericInput("width", "Width", 50, 1, 150),
numericInput("height", "Height", 50, 1, 150),
- selectInput("labelBackground", "labelBackground", choices = c(T,F)),
- selectInput("sortTitlebyCount", "sortTitlebyCount", choices = c(T,F)),
+ selectInput("labelBackground", "labelBackground", choices = c(TRUE, FALSE)),
+ selectInput("sortTitlebyCount", "sortTitlebyCount", choices = c(TRUE, FALSE)),
numericInput("labelOpacity", "labelOpacity", 0.5, 0, 1, step = 0.1),
)),
leafletOutput("map", height = 650),
@@ -76,19 +69,20 @@ server <- function(input, output, session) {
leaflet::addLayersControl(overlayGroups = c("clustermarkers")) %>%
# addCircleMarkers(data = data, group = "normalcircles", clusterOptions = markerClusterOptions()) %>%
addClusterCharts(data = data
- , options = clusterchartOptions(rmax = input$rmax,
- size = c(100,40),
- # size=40,
- width = input$width,
- height = input$height,
- strokeWidth = input$stroke,
- labelBackground = as.logical(input$labelBackground),
- # labelFill = "red",
- # labelStroke = "green",
- labelColor = "blue",
- labelOpacity = input$labelOpacity,
- innerRadius = input$innerRadius,
- sortTitlebyCount = as.logical(input$sortTitlebyCount))
+ , options = clusterchartOptions(
+ rmax = input$rmax,
+ size = c(100,40),
+ # size=40,
+ width = input$width,
+ height = input$height,
+ strokeWidth = input$stroke,
+ labelBackground = as.logical(input$labelBackground),
+ # labelFill = "red",
+ # labelStroke = "green",
+ labelColor = "blue",
+ labelOpacity = input$labelOpacity,
+ innerRadius = input$innerRadius,
+ sortTitlebyCount = as.logical(input$sortTitlebyCount))
# , type = "bar"
# , type = "horizontal"
, type = input$type
diff --git a/inst/examples/clustercharts_sum.R b/inst/examples/clustercharts_sum.R
index 8154ca7..4a2e6ca 100644
--- a/inst/examples/clustercharts_sum.R
+++ b/inst/examples/clustercharts_sum.R
@@ -25,14 +25,16 @@ shipIcon <- iconList(
## Data ##############
data <- sf::st_as_sf(breweries91)
-data$category <- sample(c("Schwer", "Mäßig", "Leicht", "kein Schaden"), size = nrow(data), replace = TRUE)
+data$category <- sample(c("Schwer", "Mäßig", "Leicht", "kein Schaden"),
+ size = nrow(data), replace = TRUE)
data$label <- paste0(data$brewery, "
", data$address)
data$id <- paste0("ID", seq.int(nrow(data)))
data$popup <- paste0("", data$brewery, "
", data$address, "
")
data$tosum <- sample(1:100, nrow(data), replace = TRUE)
data$tosumlabel <- paste("Sum: ", data$tosum)
data$web <- gsub(">(.*?)<", ">",data$tosum,"<", data$web)
-data$web <- ifelse(is.na(data$web), "", paste0("", data$web, "
"))
+data$web <- ifelse(is.na(data$web), "",
+ paste0("", data$web, "
"))
## UI ##############
ui <- fluidPage(
@@ -45,10 +47,14 @@ ui <- fluidPage(
position: absolute;
}")),
leafletOutput("map", height = 650),
- selectInput("type", "Plot type", choices = c("bar","horizontal", "custom", "pie"), selected = "custom"),
+ selectInput("type", "Plot type",
+ choices = c("bar", "horizontal", "custom", "pie"),
+ selected = "custom"),
conditionalPanel("input.type == 'custom'",
- selectInput("aggr", "Aggregation", choices = c("sum","max", "min", "mean",
- "median"), selected = "sum")
+ selectInput("aggr", "Aggregation",
+ choices = c("sum","max", "min",
+ "mean", "median"),
+ selected = "sum")
),
splitLayout(cellWidths = paste0(rep(20,4), "%"),
div(h4("Click Event"), verbatimTextOutput("click")),
@@ -65,51 +71,59 @@ server <- function(input, output, session) {
addProviderTiles("CartoDB") %>%
leaflet::addLayersControl(overlayGroups = c("clustermarkers")) %>%
# addCircleMarkers(data = data, group = "normalcircles", clusterOptions = markerClusterOptions()) %>%
- addClusterCharts(data = data
- , options = clusterchartOptions(rmax = 50,
- size = 40,
- labelBackground = TRUE,
- labelOpacity = 1,
- strokeWidth = 0.1,
- innerRadius = 20,
- digits = 0,
- sortTitlebyCount = TRUE)
- , aggregation = input$aggr
- , valueField = "tosum"
- , type = input$type
- , categoryField = "category"
- , html = "web"
- , icon = shipIcon
- , categoryMap =
- data.frame(labels = c("Schwer", "Mäßig", "Leicht", "kein Schaden"),
- colors = c("lightblue", "orange", "lightyellow", "lightgreen"))
- , group = "clustermarkers"
- , layerId = "id"
- , clusterId = "id"
- , popupFields = c("id","brewery","address","zipcode", "category","tosum")
- , popupLabels = c("id","Brauerei","Addresse","PLZ", "Art", "tosum")
- , label = "label"
- ## Options #############
- , markerOptions = markerOptions(interactive = TRUE,
- draggable = TRUE,
- keyboard = TRUE,
- title = "Some Marker Title",
- zIndexOffset = 100,
- opacity = 1,
- riseOnHover = TRUE,
- riseOffset = 400)
- , legendOptions = list(position = "bottomright", title = "Unfälle im Jahr 2003")
- , clusterOptions = markerClusterOptions(showCoverageOnHover = TRUE,
- zoomToBoundsOnClick = TRUE,
- spiderfyOnMaxZoom = TRUE,
- removeOutsideVisibleBounds = TRUE,
- spiderLegPolylineOptions = list(weight = 1.5, color = "#222", opacity = 0.5),
- freezeAtZoom = TRUE,
- clusterPane = "clusterpane",
- spiderfyDistanceMultiplier = 2
- )
- , labelOptions = labelOptions(opacity = 0.8, textsize = "14px")
- , popupOptions = popupOptions(maxWidth = 900, minWidth = 200, keepInView = TRUE)
+ addClusterCharts(
+ data = data
+ , options = clusterchartOptions(rmax = 50,
+ size = 40,
+ labelBackground = TRUE,
+ labelOpacity = 1,
+ strokeWidth = 0.1,
+ innerRadius = 20,
+ digits = 0,
+ sortTitlebyCount = TRUE)
+ , aggregation = input$aggr
+ , valueField = "tosum"
+ , type = input$type
+ , categoryField = "category"
+ , html = "web"
+ , icon = shipIcon
+ , categoryMap =
+ data.frame(labels = c("Schwer", "Mäßig",
+ "Leicht", "kein Schaden"),
+ colors = c("lightblue", "orange",
+ "lightyellow", "lightgreen"))
+ , group = "clustermarkers"
+ , layerId = "id"
+ , clusterId = "id"
+ , popupFields = c("id","brewery", "address", "zipcode",
+ "category", "tosum")
+ , popupLabels = c("id","Brauerei","Addresse","PLZ", "Art", "tosum")
+ , label = "label"
+ ## Options #############
+ , markerOptions = markerOptions(interactive = TRUE,
+ draggable = TRUE,
+ keyboard = TRUE,
+ title = "Some Marker Title",
+ zIndexOffset = 100,
+ opacity = 1,
+ riseOnHover = TRUE,
+ riseOffset = 400)
+ , legendOptions = list(position = "bottomright",
+ title = "Unfälle im Jahr 2003")
+ , clusterOptions = markerClusterOptions(
+ showCoverageOnHover = TRUE,
+ zoomToBoundsOnClick = TRUE,
+ spiderfyOnMaxZoom = TRUE,
+ removeOutsideVisibleBounds = TRUE,
+ spiderLegPolylineOptions = list(weight = 1.5, color = "#222",
+ opacity = 0.5),
+ freezeAtZoom = TRUE,
+ clusterPane = "clusterpane",
+ spiderfyDistanceMultiplier = 2
+ )
+ , labelOptions = labelOptions(opacity = 0.8, textsize = "14px")
+ , popupOptions = popupOptions(maxWidth = 900, minWidth = 200,
+ keepInView = TRUE)
)
})
output$click <- renderPrint({input$map_marker_click})
diff --git a/inst/examples/contextmenu_app.R b/inst/examples/contextmenu_app.R
index 3aef5aa..430e5b1 100644
--- a/inst/examples/contextmenu_app.R
+++ b/inst/examples/contextmenu_app.R
@@ -33,35 +33,42 @@ server <- function(input, output, session) {
output$map <- renderLeaflet({
## Basemap ####################
suppressWarnings(
- leaflet(options = leafletOptions(
- contextmenu=TRUE,
- contextmenuWidth = 200,
- contextmenuItems =
- context_mapmenuItems(
- context_menuItem("Zoom Out", "function(e) {this.zoomOut();}", disabled=TRUE),
- context_menuItem("Zoom In", "function(e) {this.zoomIn();}"),
- "-",
- context_menuItem("Disable index 0",
- "function(e) {this.contextmenu.setDisabled(0, true)}",
- hideOnSelect = TRUE),
- context_menuItem("Enable index 0",
- "function(e) {this.contextmenu.setDisabled(0, false)}",
- hideOnSelect = FALSE),
- "-",
- context_menuItem(text="Center Map",
- callback="function(e) {this.panTo(e.latlng);}",
- icon="https://cdn3.iconfinder.com/data/icons/web-15/128/RSSvgLink-2-512.png"),
- list(text="Console Log",
- callback=JS("function(e) {console.log('e');console.log(e);}"))
- ))) %>%
- addTiles(group = "base") %>%
- addContextmenu() %>%
+ leaflet(
+ options = leafletOptions(
+ contextmenu=TRUE,
+ contextmenuWidth = 200,
+ contextmenuItems =
+ context_mapmenuItems(
+ context_menuItem(
+ "Zoom Out", "function(e) {this.zoomOut();}",
+ disabled = TRUE),
+ context_menuItem(
+ "Zoom In", "function(e) {this.zoomIn();}"),
+ "-",
+ context_menuItem(
+ "Disable index 0",
+ "function(e) {this.contextmenu.setDisabled(0, true)}",
+ hideOnSelect = TRUE),
+ context_menuItem(
+ "Enable index 0",
+ "function(e) {this.contextmenu.setDisabled(0, false)}",
+ hideOnSelect = FALSE),
+ "-",
+ context_menuItem(
+ text = "Center Map",
+ callback = "function(e) {this.panTo(e.latlng);}",
+ icon = "https://cdn3.iconfinder.com/data/icons/web-15/128/RSSvgLink-2-512.png"),
+ list(text = "Console Log",
+ callback = JS("function(e) {console.log('e');console.log(e);}"))
+ ))) %>%
+ addTiles(group = "base") %>%
+ addContextmenu() %>%
## Points ###############################
addMarkers(data = sf::st_as_sf(leaflet::breweries91),
- label=~brewery, layerId = ~founded, group="marker",
+ label = ~brewery, layerId = ~founded, group = "marker",
options = markerOptions(
- contextmenu=TRUE,
+ contextmenu = TRUE,
contextmenuWidth = 200,
contextmenuItems =
context_markermenuItems(
@@ -77,16 +84,16 @@ server <- function(input, output, session) {
});
alert(e.latlng);}",
id = "somemarkerid",
- icon="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d8/Person_icon_BLACK-01.svg/1200px-Person_icon_BLACK-01.svg.png",
- index=0)
+ icon = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d8/Person_icon_BLACK-01.svg/1200px-Person_icon_BLACK-01.svg.png",
+ index = 0)
)
)) %>%
## Lines ###############################
addPolylines(data = sf::st_as_sf(leaflet::atlStorms2005),
- layerId = ~Name, group="lines",
+ layerId = ~Name, group = "lines",
label = ~Name,
options = pathOptions(
- contextmenu=TRUE,
+ contextmenu = TRUE,
contextmenuWidth = 400,
contextmenuInheritItems = FALSE,
contextmenuItems =
@@ -111,15 +118,15 @@ server <- function(input, output, session) {
"function(e) {console.log(e.relatedTarget.toGeoJSON());}",
icon = "https://cdn0.iconfinder.com/data/icons/outlinecons-filetypes/512/log-512.png",
index = 4),
- context_menuItem(text = "-", separator=TRUE,
+ context_menuItem(text = "-", separator = TRUE,
index = 5)
)
)) %>%
## Shapes ###############################
addPolygons(data = sf::st_as_sf(leaflet::gadmCHE),
- label=~NAME_1, layerId = ~OBJECTID, group="shapes",
+ label = ~NAME_1, layerId = ~OBJECTID, group = "shapes",
options = pathOptions(
- contextmenu=TRUE,
+ contextmenu = TRUE,
contextmenuWidth = 200,
contextmenuItems =
context_markermenuItems(
@@ -140,7 +147,7 @@ server <- function(input, output, session) {
context_menuItem(text = "Log GeoJSON",
"function(e) {console.log(e.relatedTarget.toGeoJSON());}",
index = 4),
- context_menuItem(text = "-", NULL, separator=TRUE,
+ context_menuItem(text = "-", NULL, separator = TRUE,
index = 5)
)
))
diff --git a/inst/examples/divicons_app.R b/inst/examples/divicons_app.R
index 79bb894..7728031 100644
--- a/inst/examples/divicons_app.R
+++ b/inst/examples/divicons_app.R
@@ -2,12 +2,12 @@ library(sf)
library(shiny)
library(leaflet)
library(leaflet.extras2)
-# options("shiny.autoreload" = TRUE)
df <- sf::st_as_sf(atlStorms2005)
df <- suppressWarnings(st_cast(df, "POINT"))
-df <- df[sample(1:nrow(df), 50, replace = F),]
-df$classes = sample(x = c("myclass1","myclass2","myclass3"), nrow(df), replace = TRUE)
+df <- df[sample(1:nrow(df), 50, replace = FALSE),]
+df$classes <- sample(x = c("myclass1", "myclass2", "myclass3"),
+ nrow(df), replace = TRUE)
df$ID <- paste0("ID_", 1:nrow(df))
## UI ##################
diff --git a/tests/testthat/test-arrowhead.R b/tests/testthat/test-arrowhead.R
index 74935c4..bd61f53 100644
--- a/tests/testthat/test-arrowhead.R
+++ b/tests/testthat/test-arrowhead.R
@@ -10,7 +10,7 @@ test_that("arrowhead", {
"addArrowhead"
)
expect_true(all(names(m$x$calls[[1]]$args[[10]]) %in%
- c("yawn", "size", "frequency", "proportionalToTotal")))
+ c("yawn", "size", "frequency", "proportionalToTotal")))
m <- leaflet() %>% clearArrowhead("groupname")
m$x$calls[[length(m$x$calls)]]$method == "clearArrowhead"
diff --git a/tests/testthat/test-clustercharts.R b/tests/testthat/test-clustercharts.R
index 23d1e73..7267b76 100644
--- a/tests/testthat/test-clustercharts.R
+++ b/tests/testthat/test-clustercharts.R
@@ -1,21 +1,19 @@
test_that("clustercharts", {
- # shipIcon <- leaflet::makeIcon(
- # iconUrl = "./icons/Icon5.svg"
- # ,className = "lsaicons"
- # ,iconWidth = 24, iconHeight = 24, iconAnchorX = 0, iconAnchorY = 0
- # )
-
## data ##########
data <- sf::st_as_sf(breweries91)
- data$category <- sample(c("Schwer", "Mäßig", "Leicht", "kein Schaden"), size = nrow(data), replace = TRUE)
+ data$category <- sample(c("Schwer", "Mäßig",
+ "Leicht", "kein Schaden"),
+ size = nrow(data), replace = TRUE)
data$label <- paste0(data$brewery, "
", data$address)
data$id <- paste0("ID", seq.int(nrow(data)))
- data$popup <- paste0("", data$brewery, "
", data$address, "
")
+ data$popup <- paste0("", data$brewery,
+ "
", data$address, "
")
data$tosum <- sample(1:100, nrow(data), replace = TRUE)
data$tosumlabel <- paste("Sum: ", data$tosum)
data$web <- gsub(">(.*?)<", ">", data$tosum, "<", data$web)
- data$web <- ifelse(is.na(data$web), "", paste0("", data$web, "
"))
+ data$web <- ifelse(is.na(data$web), "",
+ paste0("", data$web, "
"))
## simple example ##########
m <- leaflet() %>%
@@ -64,7 +62,8 @@ test_that("clustercharts", {
labels = c("Schwer", "Mäßig", "Leicht", "kein Schaden"),
colors = c("lightblue", "orange", "lightyellow", "lightgreen")
),
- popupFields = c("id", "brewery", "address", "zipcode", "category", "tosum"),
+ popupFields = c("id", "brewery", "address",
+ "zipcode", "category", "tosum"),
popupLabels = c("id", "Brauerei", "Addresse", "PLZ", "Art", "tosum")
)
deps <- findDependencies(m)
@@ -83,7 +82,8 @@ test_that("clustercharts", {
labels = c("Schwer", "Mäßig", "Leicht", "kein Schaden"),
colors = c("lightblue", "orange", "lightyellow", "lightgreen")
),
- popupFields = c("id", "brewery", "address", "zipcode", "category", "tosum")
+ popupFields = c("id", "brewery", "address",
+ "zipcode", "category", "tosum")
)
deps <- findDependencies(m)
expect_equal(deps[[length(deps)]]$name, "lfx-clustercharts")
@@ -108,7 +108,8 @@ test_that("clustercharts", {
addClusterCharts(
data = data,
categoryMap =
- data.frame(colors = c("lightblue", "orange", "lightyellow", "lightgreen"))
+ data.frame(colors = c("lightblue", "orange",
+ "lightyellow", "lightgreen"))
)
)
@@ -140,7 +141,8 @@ test_that("clustercharts", {
data = data,
categoryField = "category",
categoryMap =
- data.frame(colors = c("lightblue", "orange", "lightyellow", "lightgreen"))
+ data.frame(colors = c("lightblue", "orange",
+ "lightyellow", "lightgreen"))
)
)
deps <- findDependencies(m)
@@ -185,8 +187,10 @@ test_that("clustercharts", {
labels = c("Schwer", "Mäßig", "Leicht", "kein Schaden"),
colors = c("lightblue", "orange", "lightyellow", "lightgreen")
),
- popupFields = c("id", "brewery", "address", "zipcode", "category", "tosum", "tosum2"),
- popupLabels = c("id", "Brauerei", "Addresse", "PLZ", "Art", "tosum", "tosum2"),
+ popupFields = c("id", "brewery", "address",
+ "zipcode", "category", "tosum", "tosum2"),
+ popupLabels = c("id", "Brauerei", "Addresse",
+ "PLZ", "Art", "tosum", "tosum2"),
label = "label",
options = clusterchartOptions(size = 50)
)
@@ -222,8 +226,10 @@ test_that("clustercharts", {
labels = c("Schwer", "Mäßig", "Leicht", "kein Schaden"),
colors = c("lightblue", "orange", "lightyellow", "lightgreen")
),
- popupFields = c("id", "brewery", "address", "zipcode", "category", "tosum", "tosum2"),
- popupLabels = c("id", "Brauerei", "Addresse", "PLZ", "Art", "tosum", "tosum2"),
+ popupFields = c("id", "brewery", "address",
+ "zipcode", "category", "tosum", "tosum2"),
+ popupLabels = c("id", "Brauerei", "Addresse",
+ "PLZ", "Art", "tosum", "tosum2"),
label = "label",
options = clusterchartOptions(size = c(30, 35))
)
@@ -252,8 +258,10 @@ test_that("clustercharts", {
icons = iconvec
),
options = clusterchartOptions(size = 50),
- popupFields = c("id", "brewery", "address", "zipcode", "category", "tosum", "tosum2"),
- popupLabels = c("id", "Brauerei", "Addresse", "PLZ", "Art", "tosum", "tosum2"),
+ popupFields = c("id", "brewery", "address",
+ "zipcode", "category", "tosum", "tosum2"),
+ popupLabels = c("id", "Brauerei", "Addresse",
+ "PLZ", "Art", "tosum", "tosum2"),
label = "label"
)
deps <- findDependencies(m)
@@ -295,8 +303,10 @@ test_that("clustercharts", {
group = "clustermarkers",
layerId = "id",
clusterId = "id",
- popupFields = c("id", "brewery", "address", "zipcode", "category", "tosum", "tosum2"),
- popupLabels = c("id", "Brauerei", "Addresse", "PLZ", "Art", "tosum", "tosum2"),
+ popupFields = c("id", "brewery", "address",
+ "zipcode", "category", "tosum", "tosum2"),
+ popupLabels = c("id", "Brauerei", "Addresse",
+ "PLZ", "Art", "tosum", "tosum2"),
label = "label",
markerOptions = markerOptions(
interactive = TRUE,
@@ -308,18 +318,21 @@ test_that("clustercharts", {
riseOnHover = TRUE,
riseOffset = 400
),
- legendOptions = list(position = "bottomright", title = "Unfälle im Jahr 2003"),
+ legendOptions = list(position = "bottomright",
+ title = "Unfälle im Jahr 2003"),
clusterOptions = markerClusterOptions(
showCoverageOnHover = TRUE,
zoomToBoundsOnClick = TRUE,
spiderfyOnMaxZoom = TRUE,
removeOutsideVisibleBounds = TRUE,
- spiderLegPolylineOptions = list(weight = 1.5, color = "#222", opacity = 0.5),
+ spiderLegPolylineOptions = list(weight = 1.5,
+ color = "#222", opacity = 0.5),
freezeAtZoom = TRUE,
clusterPane = "clusterpane",
spiderfyDistanceMultiplier = 2
),
labelOptions = labelOptions(opacity = 0.8, textsize = "14px"),
- popupOptions = popupOptions(maxWidth = 900, minWidth = 200, keepInView = TRUE)
+ popupOptions = popupOptions(maxWidth = 900,
+ minWidth = 200, keepInView = TRUE)
)
})
diff --git a/tests/testthat/test-divicon.R b/tests/testthat/test-divicon.R
index 509ef3c..9078599 100644
--- a/tests/testthat/test-divicon.R
+++ b/tests/testthat/test-divicon.R
@@ -1,12 +1,11 @@
-# library(testthat)
-# library(leaflet)
library(sf)
# Sample data for testing
df <- sf::st_as_sf(atlStorms2005)
df <- suppressWarnings(st_cast(df, "POINT"))
df <- df[sample(1:nrow(df), 50, replace = FALSE), ]
-df$classes <- sample(x = c("myclass1", "myclass2", "myclass3"), nrow(df), replace = TRUE)
+df$classes <- sample(x = c("myclass1", "myclass2", "myclass3"),
+ nrow(df), replace = TRUE)
df$ID <- paste0("ID_", 1:nrow(df))
df$lon <- st_coordinates(df)[, 1]
df$lat <- st_coordinates(df)[, 2]
@@ -28,14 +27,16 @@ test_that("addDivicon works", {
className = ~ paste("globalclass", classes),
html = ~ paste0("", Name, "
")
)
- expect_true(any(sapply(map$dependencies, function(dep) dep$name == "lfx-divicon")))
+ expect_true(any(sapply(map$dependencies,
+ function(dep) dep$name == "lfx-divicon")))
expect_is(map, "leaflet")
expect_identical(map$x$calls[[2]]$method, "addDivicon")
expect_identical(map$x$calls[[2]]$args[[3]], df$ID)
expect_identical(map$x$calls[[2]]$args[[4]], NULL)
expect_identical(map$x$calls[[2]]$args[[5]], leaflet::markerOptions())
expect_identical(map$x$calls[[2]]$args[[6]], paste("globalclass", df$classes))
- expect_identical(map$x$calls[[2]]$args[[7]], paste0("", df$Name, "
"))
+ expect_identical(map$x$calls[[2]]$args[[7]],
+ paste0("", df$Name, "
"))
expect_identical(map$x$calls[[2]]$args[[8]], NULL)
expect_identical(map$x$calls[[2]]$args[[9]], NULL)
expect_identical(map$x$calls[[2]]$args[[10]], NULL)
@@ -44,7 +45,8 @@ test_that("addDivicon works", {
expect_identical(map$x$calls[[2]]$args[[13]], NULL)
# Test 2: Passing a group
- df$groups <- sample(x = c("myclass1", "myclass2", "myclass3"), nrow(df), replace = TRUE)
+ df$groups <- sample(x = c("myclass1", "myclass2", "myclass3"),
+ nrow(df), replace = TRUE)
map <- generate_test_map() %>%
addDivicon(
data = df,
@@ -59,7 +61,8 @@ test_that("addDivicon works", {
expect_identical(map$x$calls[[2]]$args[[4]], df$groups)
expect_identical(map$x$calls[[2]]$args[[5]], leaflet::markerOptions())
expect_identical(map$x$calls[[2]]$args[[6]], paste("globalclass", df$classes))
- expect_identical(map$x$calls[[2]]$args[[7]], paste0("", df$Name, "
"))
+ expect_identical(map$x$calls[[2]]$args[[7]],
+ paste0("", df$Name, "
"))
expect_identical(map$x$calls[[2]]$args[[8]], NULL)
expect_identical(map$x$calls[[2]]$args[[9]], NULL)
expect_identical(map$x$calls[[2]]$args[[10]], NULL)
@@ -86,7 +89,8 @@ test_that("addDivicon works", {
expect_identical(map$x$calls[[2]]$args[[4]], df$groups)
expect_identical(map$x$calls[[2]]$args[[5]], leaflet::markerOptions())
expect_identical(map$x$calls[[2]]$args[[6]], paste("globalclass", df$classes))
- expect_identical(map$x$calls[[2]]$args[[7]], paste0("", df$Name, "
"))
+ expect_identical(map$x$calls[[2]]$args[[7]],
+ paste0("", df$Name, "
"))
expect_identical(map$x$calls[[2]]$args[[8]], paste0(df$ID, ": ", df$Name))
expect_identical(map$x$calls[[2]]$args[[9]], popupOptions(minWidth = 400))
expect_identical(map$x$calls[[2]]$args[[10]], df$groups)
@@ -115,7 +119,8 @@ test_that("addDivicon works", {
expect_identical(map$x$calls[[2]]$args[[4]], df$groups)
expect_identical(map$x$calls[[2]]$args[[5]], leaflet::markerOptions())
expect_identical(map$x$calls[[2]]$args[[6]], paste("globalclass", df$classes))
- expect_identical(map$x$calls[[2]]$args[[7]], paste0("", df$Name, "
"))
+ expect_identical(map$x$calls[[2]]$args[[7]],
+ paste0("", df$Name, "
"))
expect_identical(map$x$calls[[2]]$args[[8]], paste0(df$ID, ": ", df$Name))
expect_identical(map$x$calls[[2]]$args[[9]], popupOptions(minWidth = 400))
expect_identical(map$x$calls[[2]]$args[[10]], df$groups)
diff --git a/tests/testthat/test-gibs.R b/tests/testthat/test-gibs.R
index 128f391..1e41622 100644
--- a/tests/testthat/test-gibs.R
+++ b/tests/testthat/test-gibs.R
@@ -29,7 +29,7 @@ test_that("gibs", {
Sys.Date() - 5
)
- m <- m %>% setTransparent(layers, transparent = F)
+ m <- m %>% setTransparent(layers, transparent = FFALSE)
expect_equal(
m$x$calls[[length(m$x$calls)]]$method,
"setTransparent"
diff --git a/tests/testthat/test-leafletsync.R b/tests/testthat/test-leafletsync.R
index ee0e3d0..cb157eb 100644
--- a/tests/testthat/test-leafletsync.R
+++ b/tests/testthat/test-leafletsync.R
@@ -4,7 +4,8 @@ test_that("Leaflet Sync works", {
expect_is(m, "leaflet")
deps <- findDependencies(m)
expect_equal(deps[[length(deps)]]$name, "lfx-leafletsync")
- expect_true(all(deps[[length(deps)]]$script %in% c("L.Map.Sync.js", "leafletsync-bindings.js")))
+ expect_true(all(deps[[length(deps)]]$script %in% c(
+ "L.Map.Sync.js", "leafletsync-bindings.js")))
m <- leaflet() %>%
diff --git a/tests/testthat/test-mapkeyicon.R b/tests/testthat/test-mapkeyicon.R
index 7841ec3..c613ddc 100644
--- a/tests/testthat/test-mapkeyicon.R
+++ b/tests/testthat/test-mapkeyicon.R
@@ -122,7 +122,7 @@ test_that("mapkey", {
addMapkeyMarkers(
lng = ~Long, lat = ~Lat,
label = ~City,
- labelOptions = rep(labelOptions(noHide = T), nrow(cities)),
+ labelOptions = rep(labelOptions(noHide = TRUE), nrow(cities)),
icon = ~ iconSet[PopCat]
)
expect_is(m, "leaflet")
@@ -132,7 +132,7 @@ test_that("mapkey", {
addMapkeyMarkers(
lng = ~Long, lat = ~Lat,
label = ~City,
- labelOptions = rep(labelOptions(noHide = T), nrow(cities)),
+ labelOptions = rep(labelOptions(noHide = TRUE), nrow(cities)),
icon = ~ iconSet[as.factor(PopCat)]
)
@@ -148,7 +148,8 @@ test_that("mapkey", {
expect_is(m, "leaflet")
expect_error(
- leaflet(cities) %>% addTiles() %>%
+ leaflet(cities) %>%
+ addTiles() %>%
addMapkeyMarkers(
lng = ~Long, lat = ~Lat, label = ~City,
icon = ~ iconSet[list()]
diff --git a/tests/testthat/test-movingmarker.R b/tests/testthat/test-movingmarker.R
index baad4ff..23286c3 100644
--- a/tests/testthat/test-movingmarker.R
+++ b/tests/testthat/test-movingmarker.R
@@ -1,6 +1,5 @@
library(sf)
## DATA #######################
-# df <- atlStorms2005[1,]
df <- new("SpatialLinesDataFrame",
data = structure(list(Name = structure(1L, levels = c(
"ALPHA",
@@ -8,7 +7,8 @@ df <- new("SpatialLinesDataFrame",
"FRANKLIN", "GAMMA", "GERT", "HARVEY", "IRENE", "JOSE", "KATRINA",
"LEE", "MARIA", "NATE", "OPHELIA", "PHILIPPE", "RITA", "TEN",
"TWENTY-TWO", "WILMA"
- ), class = "factor"), MaxWind = 45, MinPress = 998), row.names = 1L, class = "data.frame"),
+ ), class = "factor"), MaxWind = 45, MinPress = 998),
+ row.names = 1L, class = "data.frame"),
lines = list(new("Lines", Lines = list(new("Line", coords = structure(c(
-67.5,
-68.5, -69.6, -70.5, -71.3, -72.2, -72.7, -72.9, -73, -72.4,
@@ -20,7 +20,9 @@ df <- new("SpatialLinesDataFrame",
), dim = c(2L, 2L), dimnames = list(c(
"x",
"y"
- ), c("min", "max"))), proj4string = new("CRS", projargs = "+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs")
+ ), c("min", "max"))), proj4string = new(
+ "CRS",
+ projargs = "+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs")
)
## TESTS #######################
diff --git a/tests/testthat/test-osmbuildings.R b/tests/testthat/test-osmbuildings.R
index f93775e..64501ae 100644
--- a/tests/testthat/test-osmbuildings.R
+++ b/tests/testthat/test-osmbuildings.R
@@ -1,5 +1,3 @@
-# library(testthat)
-# library(leaflet)
create_test_map <- function() {
leaflet() %>% addTiles()
@@ -13,11 +11,14 @@ test_that("addBuildings adds dependencies and invokes method correctly", {
map <- addBuildings(map)
# Check if the dependencies are added
- expect_true(any(sapply(map$dependencies, function(dep) dep$name) == "lfx-building"))
+ expect_true(any(sapply(map$dependencies,
+ function(dep) dep$name) == "lfx-building"))
# Check if invokeMethod is called with correct arguments
expect_equal(map$x$calls[[2]]$method, "addBuilding")
- expect_equal(map$x$calls[[2]]$args[[1]], "https://{s}.data.osmbuildings.org/0.2/59fcc2e8/tile/{z}/{x}/{y}.json")
+ expect_equal(
+ map$x$calls[[2]]$args[[1]],
+ "https://{s}.data.osmbuildings.org/0.2/59fcc2e8/tile/{z}/{x}/{y}.json")
})
test_that("addBuildings handles custom eachFn, clickFn, and data", {
@@ -50,7 +51,8 @@ test_that("addBuildings handles custom eachFn, clickFn, and data", {
)
)
- map <- addBuildings(map, eachFn = each_fn, clickFn = click_fn, data = geojson_data)
+ map <- addBuildings(map, eachFn = each_fn,
+ clickFn = click_fn, data = geojson_data)
# Check if the JavaScript functions and data are passed correctly
expect_equal(map$x$calls[[2]]$args[[3]], each_fn)
@@ -75,7 +77,8 @@ test_that("updateBuildingTime updates the time correctly", {
# Test suite for setBuildingStyle
test_that("setBuildingStyle applies styles correctly", {
map <- create_test_map()
- style <- list(color = "#0000ff", wallColor = "#0000ff", roofColor = "blue", shadows = FALSE)
+ style <- list(color = "#0000ff", wallColor = "#0000ff",
+ roofColor = "blue", shadows = FALSE)
map <- addBuildings(map) %>%
setBuildingStyle(style) %>%
@@ -95,7 +98,8 @@ test_that("setBuildingStyle uses default styles if not provided", {
# map
# Check if invokeMethod is called with the default styles
- default_style <- list(color = "#ffcc00", wallColor = "#ffcc00", roofColor = "orange", shadows = TRUE)
+ default_style <- list(color = "#ffcc00", wallColor = "#ffcc00",
+ roofColor = "orange", shadows = TRUE)
expect_equal(map$x$calls[[3]]$"method", "setBuildingStyle")
expect_equal(map$x$calls[[3]]$args[[1]], default_style)
})
diff --git a/tests/testthat/test-playback.R b/tests/testthat/test-playback.R
index afd24d0..e75fc7a 100644
--- a/tests/testthat/test-playback.R
+++ b/tests/testthat/test-playback.R
@@ -221,7 +221,7 @@ test_that("playback", {
tickLen = 1000000,
speed = 10000000000,
fadeMarkersWhenStale = TRUE,
- dateControl = T,
+ dateControl = TRUE,
staleTime = 1,
maxInterpolationTime = 5 * 60 * 1000
),