One of the most powerful features of Targomo is the ability to quickly get A-to-B travel times for a multitude of source/target combinations. These make for great ‘heatmap’ visuals, or can be used for further analysis and aggregation.

Getting the Data

For the time service, getTargomoTimes() returns a Simple Feature Collection of 4 fields. Each feature is a POINT (corresponding to the target point), and the fields are:

  • sourceId, targetId - given IDs for the points, or inferred numeric IDs if none supplied
  • travelType - the travel mode (can supply multiple as with routes)
  • travelTime - the time taken in seconds to get from the source to the target

Integration with Leaflet

As with the polygon and route services, there are three ways to add time data to a map:

In the example below, we’ll generate some random points and use addTargomoTimes() to combine requesting the data and adding it to the map:

Drawing Options

Using addTargomoTimes() or drawTargomoTimes() you can customise the way the routes appear on the map with a call to timeDrawOptions() and timeLegendOptions(). The options available are:

timeDrawOptions

Option Default Meaning
palette "viridis" A colour palette name e.g. “Blues”, “viridis”
type "numeric" “numeric” or “bin” - continuous or discrete groupings
maxTime 1800 Maximum time to allow for (in seconds)
reverse FALSE Reverse the colour palette?
bins c(600, 1800) A number of bins or vector of cut points (only for “bin” type)
legend TRUE Add a legend to the map
legendOptions timeLegendOptions() A list of legend options - see below
radius 10 Radius of the circle markers used
stroke TRUE Whether to draw the marker border
weight 3 Stroke weight in pixels
color "black" Stroke colour
opacity 0.5 Stroke opacity
fill TRUE Fill the markers with colour (from palette)?
fillOpacity 0.5 Fill opacity

timeLegendOptions

Option Default Meaning
position "topright" Legend position on map
title "Travel Times" Legend title
layerId NULL Leaflet layer id for legend

Changing some of these options, we could re-draw the above map with smaller markers, using the inferno palette and white borders, with a different legend title and discrete bins: