addTrajPaths()
can be a powerful way of quickly plotting
trajectories on a leaflet map, but users should take some care due to any
additional arguments being passed to both leaflet::addCircleMarkers()
and
leaflet::addPolylines()
. In particular, users should be weary of the use
of the color
argument. Specifically, if color
is passed a vector of
length greater than one, multiple polylines will be drawn on top of one
another. At best this will affect opacity, but at worst this will
significantly impact the performance of R and the final leaflet map.
To mitigate this, please ensure that any vector passed to color
is of
length one. This is simple if you want the whole path to be the same
colour, but more difficult if you want to colour by a pollutant, for
example. The easiest way to achieve this is to write a for loop or use
another iterative approach (e.g. the purrr
package) to add one path per
arrival date. An example of this is provided in the Examples.