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

addGeodesicPolylines

Add Geodesic Lines


Description

Add Geodesic Lines

Usage

addGeodesicPolylines(map, lng = NULL, lat = NULL, layerId = NULL,
  group = NULL, steps = 10, wrap = TRUE, stroke = TRUE,
  color = "#03F", weight = 5, opacity = 0.5, dashArray = NULL,
  smoothFactor = 1, noClip = FALSE, popup = NULL, popupOptions = NULL,
  label = NULL, labelOptions = NULL, options = pathOptions(),
  highlightOptions = NULL, data = getMapData(map))

addGreatCircles(map, lat_center = NULL, lng_center = NULL, radius,
  layerId = NULL, group = NULL, steps = 10, wrap = TRUE,
  stroke = TRUE, color = "#03F", weight = 5, opacity = 0.5,
  dashArray = NULL, smoothFactor = 1, noClip = FALSE, popup = NULL,
  popupOptions = NULL, label = NULL, labelOptions = NULL,
  options = pathOptions(), highlightOptions = NULL,
  data = getMapData(map))

Arguments

map

map object

lng

vector of longitudes

lat

vector of latitudes

layerId

the layer id

group

the name of the group this raster image should belong to (see

steps

Defines how many intermediate points are generated along the path. More steps mean a smoother path.

wrap

Wrap line at map border (date line). Set to "false" if you want lines to cross the dateline (experimental, see noWrap-example on how to use)

stroke

whether to draw stroke along the path (e.g. the borders of polygons or circles)

color

stroke color

weight

stroke width in pixels

opacity

stroke opacity (or layer opacity for tile layers)

dashArray

a string that defines the stroke dash pattern

smoothFactor

how much to simplify the polyline on each zoom level

noClip

whether to disable polyline clipping (more means better performance and less accurate representation)

popup

a character vector of the HTML content for the popups (you are recommended to escape the text using htmlEscape()

popupOptions

A Vector of popupOptions to provide popups for security reasons)

label

a character vector of the HTML content for the labels

labelOptions

A Vector of labelOptions to provide label options for each label. Default NULL

options

a list of additional options, intended to be provided by a call to pathOptions()

highlightOptions

Options for highlighting the shape on mouse over.

data

map data

lat_center, lng_center

lat/lng for the center

radius

in meters

Functions

  • addGreatCircles: Adds a Great Circle to the map

Examples

berlin <- c(52.51, 13.4)
losangeles <- c(34.05, -118.24)
santiago <- c(-33.44, -70.71)
tokio <- c(35.69, 139.69)
sydney <- c(-33.91, 151.08)
capetown <- c(-33.91, 18.41)
calgary <- c(51.05, -114.08)
hammerfest <- c(70.67, 23.68)
barrow <- c(71.29, -156.76)

df <- as.data.frame(rbind(hammerfest, calgary, losangeles, santiago, capetown, tokio, barrow))
names(df) <- c("lat","lng")

leaflet(df) %>%
  addProviderTiles(providers$CartoDB.Positron) %>%
  addGeodesicPolylines(lng = ~lng, lat = ~lat, weight = 2, color = "red",
                       steps = 50, opacity = 1) %>%
  addCircleMarkers(df, lat = ~lat,lng = ~lng, radius = 3, stroke = FALSE,
                   fillColor = "black", fillOpacity = 1)

## for more examples see
# browseURL(system.file("examples/geodesic.R", package = "leaflet.extras"))

leaflet.extras

Extra Functionality for 'leaflet' Package

v1.0.0
GPL-3 | file LICENSE
Authors
Bhaskar Karambelkar [aut, cre], Barret Schloerke [aut], Bangyou Zheng [ctb] (Leaflet-search and Leaflet-GPS plugin integration), Robin Cura [ctb] (Fixes for Draw Options), Markus Voge [ctb] (Enhancements for Draw Options), Markus Dumke [ctb] (Bounce Marker addition), Mapbox [ctb, cph] (leaflet-omnivore, csv2geojson, and togeojson libraries), Henry Thasler [ctb, cph] (Leaflet.Geodesic library), Dennis Wilhelm [ctb, cph] (Leaflet.StyleEditor library), Kirollos Risk [ctb, cph] (fuse.js library), Tim Wisniewski [ctb, cph] (leaflet-choropleth library), Leaflet [ctb, cph] (leaflet-draw library), Alexander Milevski [ctb, cph] (leaflet-draw-drag library), John Firebaugh [ctb, cph] (leaflet-fullscreen library), Stefano Cudini [ctb, cph] (leaflet-gps library), Johannes Rudolph [ctb, cph] (leaflet-hash library), Per Liedman [ctb, cph] (leaflet-measure-path library), Pavel Shramov [ctb, cph] (leaflet-plugins library), Filip Zavadil [ctb, cph] (leaflet-pulse-icon library), Stefano Cudini [ctb, cph] (leaflet-search library), CliffCloud [ctb, cph] (leaflet-sleep library), Ursudio [ctb, cph] (leaflet-webgl-heatmap library), Maxime Hadjinlian [ctb, cph] (leaflet.BounceMarker library), Vladimir Agafonkin [ctb, cph] (leaflet.heat library), Iván Sánchez Ortega [ctb, cph] (leaflet.tilelayer.pouchdbcached library), Dale Harvey [ctb, cph] (pouchdb-browser library), Mike Bostock [ctb, cph] (topojson library)
Initial release

We don't support your browser anymore

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