-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from eodaGmbH/nfr
Add marker update documentation
- Loading branch information
Showing
12 changed files
with
108 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#' Create a Marker | ||
#' | ||
#' @param lngLat | ||
#' @param popup | ||
#' @export | ||
#' @example examples/markers.R | ||
Marker <- function(lngLat, popup , ...) { | ||
mark <- list( | ||
lngLat = lngLat, | ||
popup = popup, | ||
options = MarkerOptions(...) | ||
) |> | ||
purrr::compact() | ||
class(mark) <- "MapLibreMarker" | ||
return(mark) | ||
} | ||
|
||
MarkerOptions <- function(...){ | ||
marker_options <- list(...) | ||
stopifnot(sapply(marker_options[c("anchor", "color", "pitchAlignment", "rotationAlignment")], function(x){is.null(x) | is.character(x)})) | ||
stopifnot(sapply(marker_options["draggable"], function(x) {is.null(x) | is.logical(x)})) | ||
stopifnot(sapply(marker_options[c("rotation", "scale")], function(x) {is.null(x) | is.numeric(x)})) | ||
marker_options <- marker_options |> | ||
purrr::compact() | ||
class(marker_options) <- "MarkerOptions" | ||
return(marker_options) | ||
} | ||
|
||
#' Add a marker to map | ||
#' | ||
#' @param .map | ||
#' @param marker | ||
#' | ||
#' @export | ||
#' @example examples/markers.R | ||
add_marker <- function(.map, marker) { | ||
.map |> add_call("addMarker", marker) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
test <- mapOptions( | ||
map_options <- mapOptions( | ||
center = c(-123.1256, 49.24658), | ||
hash = TRUE, | ||
pitch = 0, | ||
style = basemaps$carto$dark_matter, | ||
test = NULL | ||
) | ||
maplibre(test, zoom = 12) |> | ||
maplibre(map_options, zoom = 12) |> | ||
add_control("NavigationControl", "top-left", showCompass = F) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
library(maplibre) | ||
marker = Marker( | ||
lngLat = c(9.5,51.31667), | ||
popup = list(text = "This is a marker",options = list(closeButton = F)), | ||
color= "darkred" | ||
) | ||
|
||
maplibre(mapOptions(center = c(9.5,51.31667)),zoom = 4) |> | ||
add_marker(marker) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.