Primarily designed to work with rgeo()
to display randomly sampled
points on the globe.
leaflet_map(
latitude = NULL,
longitude = NULL,
position = NULL,
zoom = 12,
mark = FALSE,
radius = 0,
units = c("km", "miles", "meters", "feet"),
...
)
vectors of latitude and longitude values.
If latitude
is a data frame, then it is treated as position
.
This facilitates "piping" from rgeo()
. See examples.
a data frame containing latitude and longitude positions
zoom level for initial map (1-20)
a logical indicating whether the location should be marked with a pin
a vector of radii of circles (in miles) centered at position that are displayed on the map
units for radii of circles (km, miles, meters, or feet).
additional arguments passed to leaflet::addCircles()
a leaflet map
deg2rad()
, latlon2xyz()
and rgeo()
.
# the leaflet package is required
if (require(leaflet)) {
# Times Square
leaflet_map(40.7566, -73.9863, radius = 1, units = "miles")
# 3 random locations; 5 km circles
leaflet_map(position = rgeo(3), radius = 5, mark = TRUE, color = "red")
# using pipes
rgeo(4, latlim = c(25,50), lonlim = c(-65, -125)) |>
leaflet_map(radius = 5, mark = TRUE, color = "purple")
}
#> Loading required package: leaflet