Skip to content

Commit

Permalink
merge styler
Browse files Browse the repository at this point in the history
Merge branch 'develop' of https:/trafficonese/leaflet.extras into develop

# Conflicts:
#	tests/testthat/test-geojson.R
  • Loading branch information
trafficonese committed Mar 19, 2024
2 parents 2356a0c + 3be4bdd commit 5537161
Show file tree
Hide file tree
Showing 9 changed files with 436 additions and 307 deletions.
121 changes: 59 additions & 62 deletions R/geodesic.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,28 @@ NULL
#' ## for more examples see
#' # browseURL(system.file("examples/geodesic.R", package = "leaflet.extras"))
addGeodesicPolylines <- function(
map, lng = NULL, lat = NULL, layerId = NULL, group = NULL,
steps = 10,
wrap = TRUE,
stroke = TRUE,
color = "#03F",
weight = 5,
opacity = 0.5,
dashArray = NULL,
smoothFactor = 1.0,
noClip = FALSE,
popup = NULL,
popupOptions = NULL,
label = NULL,
labelOptions = NULL,
options = pathOptions(),
# highlightOptions = NULL,
icon = NULL,
showCenter = TRUE,
showStats = FALSE,
statsFunction = NULL,
markerOptions = NULL,
data = getMapData(map)
) {
map, lng = NULL, lat = NULL, layerId = NULL, group = NULL,
steps = 10,
wrap = TRUE,
stroke = TRUE,
color = "#03F",
weight = 5,
opacity = 0.5,
dashArray = NULL,
smoothFactor = 1.0,
noClip = FALSE,
popup = NULL,
popupOptions = NULL,
label = NULL,
labelOptions = NULL,
options = pathOptions(),
# highlightOptions = NULL,
icon = NULL,
showCenter = TRUE,
showStats = FALSE,
statsFunction = NULL,
markerOptions = NULL,
data = getMapData(map)) {
map$dependencies <- c(map$dependencies, geodesicDependencies())

options <- c(options, list(
Expand All @@ -91,18 +90,16 @@ addGeodesicPolylines <- function(

if (inherits(icon, "leaflet_icon_set")) {
icon <- iconSetToIcons(icon)
}
else if (inherits(icon, "leaflet_awesome_icon_set") || inherits(icon, "leaflet_awesome_icon")) {
} else if (inherits(icon, "leaflet_awesome_icon_set") || inherits(icon, "leaflet_awesome_icon")) {
if (inherits(icon, "leaflet_awesome_icon_set")) {
libs <- unique(unlist(lapply(icon, function(x) x[["library"]])))
map <- addAwesomeMarkersDependencies(map, libs)
icon <- awesomeIconSetToAwesomeIcons(icon)
} else {
map <- addAwesomeMarkersDependencies(map, icon$library)
}
icon$awesomemarker = TRUE
}
else {
icon$awesomemarker <- TRUE
} else {
icon$iconUrl <- b64EncodePackedIcons(packStrings(icon$iconUrl))
icon$iconRetinaUrl <- b64EncodePackedIcons(packStrings(icon$iconRetinaUrl))
icon$shadowUrl <- b64EncodePackedIcons(packStrings(icon$shadowUrl))
Expand All @@ -117,12 +114,14 @@ addGeodesicPolylines <- function(
icon <- leaflet::filterNULL(icon)
}

pgons = leaflet::derivePolygons(
data, lng, lat, missing(lng), missing(lat), "addGeodesicPolylines")
pgons <- leaflet::derivePolygons(
data, lng, lat, missing(lng), missing(lat), "addGeodesicPolylines"
)
leaflet::invokeMethod(
map, data, "addGeodesicPolylines", pgons, layerId, group, options, icon,
popup, popupOptions, safeLabel(label, data), labelOptions, NULL,
markerOptions) %>%
markerOptions
) %>%
leaflet::expandLimitsBbox(pgons)
}

Expand All @@ -144,30 +143,29 @@ addLatLng <- function(map, lat, lng, layerId = NULL) {
#' @param showStats Show Statistics Info
#' @inheritParams leaflet::markerOptions
addGreatCircles <- function(
map, lat_center = NULL, lng_center = NULL, radius, layerId = NULL, group = NULL,
steps = 10,
wrap = TRUE,
stroke = TRUE,
color = "#03F",
weight = 5,
opacity = 0.5,
dashArray = NULL,
smoothFactor = 1.0,
noClip = FALSE,
popup = NULL,
popupOptions = NULL,
label = NULL,
labelOptions = NULL,
options = pathOptions(),
highlightOptions = NULL,
icon = NULL,
fill = TRUE,
showCenter = TRUE,
showStats = FALSE,
statsFunction = NULL,
markerOptions = NULL,
data = getMapData(map)
) {
map, lat_center = NULL, lng_center = NULL, radius, layerId = NULL, group = NULL,
steps = 10,
wrap = TRUE,
stroke = TRUE,
color = "#03F",
weight = 5,
opacity = 0.5,
dashArray = NULL,
smoothFactor = 1.0,
noClip = FALSE,
popup = NULL,
popupOptions = NULL,
label = NULL,
labelOptions = NULL,
options = pathOptions(),
highlightOptions = NULL,
icon = NULL,
fill = TRUE,
showCenter = TRUE,
showStats = FALSE,
statsFunction = NULL,
markerOptions = NULL,
data = getMapData(map)) {
map$dependencies <- c(map$dependencies, geodesicDependencies())

if (!is.null(icon)) {
Expand All @@ -177,18 +175,16 @@ addGreatCircles <- function(

if (inherits(icon, "leaflet_icon_set")) {
icon <- iconSetToIcons(icon)
}
else if (inherits(icon, "leaflet_awesome_icon_set") || inherits(icon, "leaflet_awesome_icon")) {
} else if (inherits(icon, "leaflet_awesome_icon_set") || inherits(icon, "leaflet_awesome_icon")) {
if (inherits(icon, "leaflet_awesome_icon_set")) {
libs <- unique(unlist(lapply(icon, function(x) x[["library"]])))
map <- addAwesomeMarkersDependencies(map, libs)
icon <- awesomeIconSetToAwesomeIcons(icon)
} else {
map <- addAwesomeMarkersDependencies(map, icon$library)
}
icon$awesomemarker = TRUE
}
else {
icon$awesomemarker <- TRUE
} else {
icon$iconUrl <- b64EncodePackedIcons(packStrings(icon$iconUrl))
icon$iconRetinaUrl <- b64EncodePackedIcons(packStrings(icon$iconRetinaUrl))
icon$shadowUrl <- b64EncodePackedIcons(packStrings(icon$shadowUrl))
Expand All @@ -215,7 +211,8 @@ addGreatCircles <- function(
"addGreatCircles"
)
leaflet::invokeMethod(
map, data, "addGreatCircles", points$lat, points$lng, radius, layerId, group, options, icon,
popup, popupOptions, safeLabel(label, data), labelOptions, highlightOptions, markerOptions) %>%
map, data, "addGreatCircles", points$lat, points$lng, radius, layerId, group, options, icon,
popup, popupOptions, safeLabel(label, data), labelOptions, highlightOptions, markerOptions
) %>%
leaflet::expandLimits(points$lat, points$lng)
}
Loading

0 comments on commit 5537161

Please sign in to comment.