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

mapOptions

Set options on a leaflet map object


Description

Set options on a leaflet map object

Usage

mapOptions(map, zoomToLimits = c("always", "first", "never"))

Arguments

map

A map widget object created from leaflet()

zoomToLimits

Controls whether the map is zooms to the limits of the elements on the map. This is useful for interactive applications where the map data is updated. If "always" (the default), the map always re-zooms when new data is received; if "first", it zooms to the elements on the first rendering, but does not re-zoom for subsequent data; if "never", it never re-zooms, not even for the first rendering.

Examples

# Don't auto-zoom to the objects (can be useful in interactive applications)
leaflet() %>%
  addTiles() %>%
  addPopups(174.7690922, -36.8523071, "R was born here!") %>%
  mapOptions(zoomToLimits = "first")

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.