leaflet_map: Simple Leaflet Maps

View source: R/rgeo.R

leaflet_mapR Documentation

Simple Leaflet Maps

Description

Primarily designed to work with rgeo() to display randomly sampled points on the globe.

Usage

leaflet_map(
  latitude = NULL,
  longitude = NULL,
  position = NULL,
  zoom = 12,
  mark = FALSE,
  radius = 0,
  units = c("km", "miles", "meters", "feet"),
  ...
)

Arguments

latitude, longitude

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.

position

a data frame containing latitude and longitude positions

zoom

zoom level for initial map (1-20)

mark

a logical indicating whether the location should be marked with a pin

radius

a vector of radii of circles (in miles) centered at position that are displayed on the map

units

units for radii of circles (km, miles, meters, or feet).

...

additional arguments passed to leaflet::addCircles()

Value

a leaflet map

See Also

deg2rad(), latlon2xyz() and rgeo().

Examples

# 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")
}

mosaic documentation built on May 29, 2024, 5:27 a.m.