Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

addMeasure

Add a measure control to the map.


Description

Add a measure control to the map.

Usage

addMeasure(
  map,
  position = "topright",
  primaryLengthUnit = "feet",
  secondaryLengthUnit = NULL,
  primaryAreaUnit = "acres",
  secondaryAreaUnit = NULL,
  activeColor = "#ABE67E",
  completedColor = "#C8F2BE",
  popupOptions = list(className = "leaflet-measure-resultpopup", autoPanPadding = c(10,
    10)),
  captureZIndex = 10000,
  localization = "en",
  decPoint = ".",
  thousandsSep = ","
)

Arguments

map

a map widget object

position

standard Leaflet control position options.

primaryLengthUnit, secondaryLengthUnit

units used to display length results. secondaryLengthUnit is optional. Valid values are "feet", "meters", "miles", and "kilometers".

primaryAreaUnit, secondaryAreaUnit

units used to display area results. secondaryAreaUnit is optional. Valid values are "acres", "hectares", "sqmeters", and "sqmiles".

activeColor

base color to use for map features rendered while actively performing a measurement. Value should be a color represented as a hexadecimal string.

completedColor

base color to use for features generated from a completed measurement. Value should be a color represented as a hexadecimal string.

popupOptions

list of options applied to the popup of the resulting measure feature. Properties may be any standard Leaflet popup options.

captureZIndex

Z-index of the marker used to capture measure clicks. Set this value higher than the z-index of all other map layers to disable click events on other layers while a measurement is active.

localization

Locale to translate displayed text. Available locales include en (default), cn, de, es, fr, it, nl, pt, pt_BR, pt_PT, ru, and tr

decPoint

Decimal point used when displaying measurements. If not specified, values are defined by the localization.

thousandsSep

Thousands separator used when displaying measurements. If not specified, values are defined by the localization.

Value

modified map

Examples

leaf <- leaflet() %>%
  addTiles() %>%
  # central park
  fitBounds( -73.9, 40.75, -73.95, 40.8 ) %>%
  addMeasure()

leaf

# customizing
leaf %>% addMeasure(
  position = "bottomleft",
  primaryLengthUnit = "meters",
  primaryAreaUnit = "sqmeters",
  activeColor = "#3D535D",
  completedColor = "#7D4479",
  localization = "de"
)

leaflet

Create Interactive Web Maps with the JavaScript 'Leaflet' Library

v2.0.4.1
GPL-3
Authors
Joe Cheng [aut, cre], Bhaskar Karambelkar [aut], Yihui Xie [aut], Hadley Wickham [ctb], Kenton Russell [ctb], Kent Johnson [ctb], Barret Schloerke [ctb], jQuery Foundation and contributors [ctb, cph] (jQuery library), Vladimir Agafonkin [ctb, cph] (Leaflet library), CloudMade [cph] (Leaflet library), Leaflet contributors [ctb] (Leaflet library), Brandon Copeland [ctb, cph] (leaflet-measure plugin), Joerg Dietrich [ctb, cph] (Leaflet.Terminator plugin), Benjamin Becquet [ctb, cph] (Leaflet.MagnifyingGlass plugin), Norkart AS [ctb, cph] (Leaflet.MiniMap plugin), L. Voogdt [ctb, cph] (Leaflet.awesome-markers plugin), Daniel Montague [ctb, cph] (Leaflet.EasyButton plugin), Kartena AB [ctb, cph] (Proj4Leaflet plugin), Robert Kajic [ctb, cph] (leaflet-locationfilter plugin), Mapbox [ctb, cph] (leaflet-omnivore plugin), Michael Bostock [ctb, cph] (topojson), RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.