geodesics {leaflet.extras} | R Documentation |
Add Geodesic Lines & Circles
Description
A geodesic line is the shortest path between two given positions on the earth surface. It's based on Vincenty's formulae implemented by Chris Veness for highest precision.
Add Lat/Long to a Geodesic Polyline.
Adds a Great Circle to the map.
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,
icon = NULL,
showMarker = FALSE,
showStats = FALSE,
statsFunction = NULL,
markerOptions = NULL,
data = getMapData(map)
)
addLatLng(map, lat, lng, layerId = NULL)
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,
icon = NULL,
fill = TRUE,
showMarker = FALSE,
showStats = FALSE,
statsFunction = NULL,
markerOptions = NULL,
data = getMapData(map)
)
Arguments
map |
a map widget object created from |
lat , lng |
lat/lng to add to the Geodesic |
layerId |
the layer id |
group |
the name of the group the newly created layers should belong to
(for |
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 (more means better performance and less accurate representation) |
noClip |
whether to disable polyline clipping |
popup |
a character vector of the HTML content for the popups (you are
recommended to escape the text using |
popupOptions |
A Vector of |
label |
a character vector of the HTML content for the labels |
labelOptions |
A Vector of |
options |
a list of extra options for tile layers, popups, paths (circles, rectangles, polygons, ...), or other map elements |
highlightOptions |
Options for highlighting the shape on mouse over. |
icon |
the icon(s) for markers; an icon is represented by an R list of
the form |
showMarker |
Should the nodes/center points be visualized as Markers? |
showStats |
This will create an L.Control with some information on the geodesics |
statsFunction |
A custom JS function to be showed in the info control |
markerOptions |
List of options for the markers. See |
data |
the data object from which the argument values are derived; by
default, it is the |
lat_center , lng_center |
lat/lng for the center |
radius |
in meters |
fill |
whether to fill the path with color (e.g. filling on polygons or circles) |
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"))