Description Usage Arguments Value Examples
These functions can be used to represent flows and their evolution on a map
created with leaflet()
. Flows are simply represented
by a segment between two points with an arrow at its center that indicates the
direction of the flow.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | addFlows(
map,
lng0,
lat0,
lng1,
lat1,
color = "blue",
flow = 1,
opacity = 1,
dir = NULL,
time = NULL,
popup = popupArgs(labels = "Flow"),
layerId = NULL,
timeFormat = NULL,
initialTime = NULL,
maxFlow = max(abs(flow)),
minThickness = 1,
maxThickness = 20,
popupOptions = NULL
)
updateFlows(
map,
layerId,
color = NULL,
flow = NULL,
opacity = NULL,
dir = NULL,
time = NULL,
popup = NULL,
timeFormat = NULL,
initialTime = NULL,
maxFlow = NULL,
minThickness = 1,
maxThickness = 20,
popupOptions = NULL
)
removeFlows(map, layerId)
clearFlows(map)
|
map |
A leaflet map object created with |
lng0 |
Longitude of the origin of the flow. |
lat0 |
Latitude of the origin of the flow. |
lng1 |
Longitude of the destination of the flow. |
lat1 |
Latitude of the destination of the flow. |
color |
Color of the flow. |
flow |
Value of the flow between the origin and the destination. If
argument |
opacity |
Opacity of the flow. |
dir |
Direction of the flow. 1 indicates that the flow goes from origin
to destination and -1 indicates that it goes from destination to origin. If
0, the arrow is not drawn. If |
time |
A vector with length equal to the number of rows in |
popup |
Options that control popup generation. |
layerId |
An ID variable. It is mandatory when one wants to update some
chart with |
timeFormat |
Character string used to format dates and times when
argument |
initialTime |
This argument can be used to set the initial time step
shown when the map is created. It is used only when argument |
maxFlow |
Maximal value a flow could take. |
minThickness |
minimal thickness of the line that represents the flow. |
maxThickness |
maximal thickness of the line that represents the flow. |
popupOptions |
Change default popupOptions (ex : autoClose, maxHeight, closeButton ...)
See |
The modified leaflet map object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | require(leaflet)
# Toy example
leaflet() %>% addTiles() %>%
addFlows(0, 0, 1, 1, flow = 10)
# Electric exchanges between France and neighboring countries
data("eco2mixBalance")
bal <- eco2mixBalance
leaflet() %>% addTiles() %>%
addFlows(
bal$lng0, bal$lat0, bal$lng1, bal$lat1,
flow = bal$balance,
time = bal$month
)
# popupOptions
data("eco2mixBalance")
bal <- eco2mixBalance
leaflet() %>% addTiles() %>%
addFlows(
bal$lng0, bal$lat0, bal$lng1, bal$lat1,
flow = bal$balance,
time = bal$month,
popupOptions = list(closeOnClick = FALSE, autoClose = FALSE)
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.