Skip to content

Commit c58926f

Browse files
committed
leaflet-measure plugin upgraded to 2.0.2 with support for localization.
1 parent 5abd3f4 commit c58926f

17 files changed

+7415
-4
lines changed

R/plugin-measure.R

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ leafletMeasureDependencies <- function() {
22
list(
33
htmltools::htmlDependency(
44
"leaflet-measure",
5-
"1.2.0",
5+
"2.0.2",
66
system.file("htmlwidgets/lib/leaflet-measure", package = "leaflet"),
77
script = "leaflet-measure.min.js",
88
stylesheet = "leaflet-measure.css"
@@ -29,6 +29,16 @@ leafletMeasureDependencies <- function() {
2929
#' @param popupOptions \code{list} of ptions applied to the popup
3030
#' of the resulting measure feature.
3131
#' Properties may be any \href{http://leafletjs.com/reference.html#popup-options}{standard Leaflet popup options}.
32+
#' @param captureZIndex Z-index of the marker used to capture measure clicks.
33+
#' Set this value higher than the z-index of all other map layers to
34+
#' disable click events on other layers while a measurement is active.
35+
#' @param localization Locale to translate displayed text.
36+
#' Available locales include en (default), cn, de, es, fr, it, nl, pt,
37+
#' pt_BR, pt_PT, ru, and tr
38+
#' @param decPoint Decimal point used when displaying measurements.
39+
#' If not specified, values are defined by the localization.
40+
#' @param thousandsSep Thousands separator used when displaying measurements.
41+
#' If not specified, values are defined by the localization.
3242
#'
3343
#' @return modified map
3444
#' @examples
@@ -49,6 +59,7 @@ leafletMeasureDependencies <- function() {
4959
#' , primaryAreaUnit = "sqmeters"
5060
#' , activeColor = "#3D535D"
5161
#' , completedColor = "#7D4479"
62+
#' , localization = 'de'
5263
#' )
5364
#'
5465
#' @export
@@ -62,6 +73,10 @@ addMeasure <- function(
6273
, activeColor = "#ABE67E"
6374
, completedColor ="#C8F2BE"
6475
, popupOptions = list( className = 'leaflet-measure-resultpopup', autoPanPadding = c(10,10) )
76+
, captureZIndex = 10000
77+
, localization = 'en'
78+
, decPoint = '.'
79+
, thousandsSep = ','
6580
) {
6681
map$dependencies <- c(map$dependencies, leafletMeasureDependencies())
6782
invokeMethod(
@@ -79,6 +94,10 @@ addMeasure <- function(
7994
, activeColor = activeColor
8095
, completedColor = completedColor
8196
, popupOptions = popupOptions
97+
, captureZIndex = captureZIndex
98+
, localization = localization
99+
, decPoint = decPoint
100+
, thousandsSep = thousandsSep
82101
)
83102
)
84103
)

inst/examples/leaflet-measure.R

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
library(leaflet)
2+
3+
leaf <- leaflet() %>%
4+
addTiles()
5+
6+
#' <br/>
7+
#' Default Behavior
8+
leaf %>%
9+
# central park
10+
fitBounds(-73.9, 40.75, -73.95,40.8) %>%
11+
addMeasure()
12+
13+
#' <br/>
14+
#' Customization
15+
leaf %>%
16+
# Berling, Germany with German localization
17+
fitBounds(13.76134, 52.675499, 13.0884, 52.33812) %>%
18+
addMeasure(
19+
position = "bottomleft",
20+
primaryLengthUnit = "meters",
21+
primaryAreaUnit = "sqmeters",
22+
activeColor = "#3D535D",
23+
completedColor = "#7D4479",
24+
localization='de'
25+
)
-70 Bytes
Loading
-106 Bytes
Loading
-49 Bytes
Loading
-35 Bytes
Loading
-19 Bytes
Loading
-67 Bytes
Loading
-5 Bytes
Loading
-18 Bytes
Loading

0 commit comments

Comments
 (0)