Skip to main content
GuidesAPI ReferenceExamplesFAQ

Routes

Estimated reading time: 11 minutes

A Route usually represents a navigable path between two or more landmarks (waypoints). It includes data such as distance, estimated time, and navigation instructions.

Routes can be computed in different ways:

  • Based on 2 or more intermediary landmarks (waypoints) - route is navigable.
  • Over-track routes (based on a predefined path, which could come from a GPX file but is not limited to this) are navigable.
  • Route ranges: These routes are not navigable and do not have segments or instructions.

A navigable route consists of one or more segments. Each segment represents the portion of the route between two consecutive waypoints and includes its own set of route instructions.

Instantiating Routes

Routes cannot be instantiated directly. Instead, they must be computed based on a predefined list of landmarks. For detailed guidance on how to calculate routes, refer to the Getting Started with Routing Guide.

warning

Calculating a route does not automatically display it on the map. Refer to the Display markers guide for detailed instructions on how to display one or more routes.

Route specializations

The Maps SDK for Flutter supports multiple routes types, each tailored for specific use cases and implemented through dedicated classes:

  1. Normal Routes - Standard routes computed for typical navigation scenarios.

  2. Public Transport (PT) Routes - Routes calculated using a public transport mode, providing additional details such as frequency, ticket purchase information, and other public transport-specific data.

  3. Over-Track (OT) Routes - Routes generated based on a predefined path, such as those derived from GPX files or routes drawn with the finder.

  4. Electric Vehicle (EV) Routes - Not fully implemented at the moment. Are designed for EV-specific needs, including charging station information and related details.

Specific Classes

Each route type is associated with specific classes that offer functionality suited to its requirements:

Route TypeRoute ClassSegment ClassInstruction Class
Normal RouteRouteRouteSegmentRouteInstruction
Public Transport RoutePTRoutePTRouteSegmentPTRouteInstruction
Over-Track RouteOTRouteNot AvailableNot Available
Electric Vehicle RouteEVRouteEVRouteSegmentEVRouteInstruction

The specific classes extend the functionality of the base classes RouteBase, RouteSegmentBase, RouteInstructionBase that provide the common features for each type of entity.

Route structure

The most important route characteristics are:

FieldTypeExplanation
geographicAreaGeographicAreaA geographic boundary or region covered by the route.
polygonGeographicAreaPolygonGeographicAreaA polygon representing the geographic area as a series of connected points.
tilesGeographicAreaTilesCollectionGeographicAreaA collection of map tiles representing the geographic area.
dominantRoadsList<String>A list of road names or identifiers that dominate the route.
hasFerryConnectionsboolIndicates whether the route includes ferry connections.
hasTollRoadsboolIndicates whether the route includes toll roads.
incursCostsboolSpecifies if the route incurs any monetary costs, such as tolls or fees [DEPRECATED - same as hasTollRoads]
routeStatusRouteStatusIf we are navigating a route and we deviate from it, the route is recalculated. This means that the routeStatus might signal that route is computed or we don't have internet connection, or even that on recomputation we got an error.
terrainProfileList<double>A profile of terrain elevations along the route, represented as a list of elevation values.
segmentsList<RouteSegment>
A collection of route segments, each representing a specific portion of the route.
Segments are split based on the initial waypoints that were used to compute the route.
For Public Transit routes a segment is either a pedestrian part or a public transit part.
trafficEventsList<RouteTrafficEvent>A list of traffic events, such as delays or road closures, affecting the route.

RouteSegment structure

A route segment represents the portion of a route between two consecutive waypoints. For public transport routes, segments are further categorized as either pedestrian sections or public transit sections, depending on the mode of travel within that segment.

Field/MethodReturn TypeDescription
waypointsList<Landmark>Retrieves the list of landmarks representing the start and end waypoints of the route segment.
timeDistanceTimeDistanceProvides the length in meters and estimated travel time in seconds for the route segment.
geographicAreaRectangleGeographicAreaRetrieves the smallest rectangle enclosing the geographic area of the route.
incursCostsboolChecks whether traveling the route or segment incurs a cost to the user.
summaryStringProvides a summary of the route segment.
instructionsList<RouteInstruction>Retrieves the list of route instructions for the segment.
isCommonboolIndicates whether the segment shares the same travel mode as the parent route. Mostly used within public transport routes.

RouteInstruction structure

A route instruction provides detailed guidance for navigation, offering various methods to retrieve specific information about each maneuver the user needs to make, such as coordinates, turn directions, distances and time to next waypoints.

MethodReturn TypeDescription
coordinatesCoordinatesGets coordinates for this route instruction.
countryCodeISOStringGets ISO 3166-1 alpha-3 country code for the navigation instruction.
exitDetailsStringGets exit route instruction text.
followRoadInstructionStringGets textual description for follow road information.
realisticNextTurnImgAbstractGeometryImgGets image for the realistic turn information.
remainingTravelTimeDistanceTimeDistanceGets remaining travel time and distance until the destination
remainingTravelTimeDistanceToNextWaypointTimeDistanceGets remaining travel time and distance to the next waypoint.
roadInfoList<RoadInfo>Gets road information.
roadInfoImgRoadInfoImgGets road information image.
signpostDetailsSignpostDetailsGets extended signpost details.
signpostInstructionStringGets textual description for the signpost information.
timeDistanceToNextTurnTimeDistanceGets distance and time to the next turn.
traveledTimeDistanceTimeDistanceGets traveled time and distance.
turnDetailsTurnDetailsGets full details for the turn.
turnImgImgGets image for the turn.
turnInstructionStringGets textual description for the turn.
hasFollowRoadInfoboolChecks if follow road information is available.
hasSignpostInfoboolChecks if signpost information is available.
hasTurnInfoboolChecks if turn information is available.
hasRoadInfoboolChecks if road information is available.
isCommonboolChecks if this instruction is of common type - has the same transport mode as the parent route
isExitboolChecks if the route instruction is a main road exit instruction.
isFerryboolChecks if the route instruction is on a ferry segment.
isTollRoadboolChecks if the route instruction is on a toll road.
note

It is important to distinguish between NavigationInstruction and RouteInstruction. NavigationInstruction offers real-time, turn-by-turn navigation based on the user's current position and is relevant only during navigation or simulation. In contrast, RouteInstruction provides an overview of the entire route available as soon as the route is calculated and the list of instructions do not change as the user navigates on the route.

Other classes

Time distance

The TimeDistance class is used to get details about the time and distance to/from certain important points of interests.

The TimeDistance class differentiates between unrestricted and restricted road portions. Restricted segments refer to non-public roads, while unrestricted represent publicly accessible roads:

FieldTypeExplanation
unrestrictedTimeSintUnrestricted time in seconds.
restrictedTimeSintRestricted time in seconds.
unrestrictedDistanceMintUnrestricted distance in meters.
restrictedDistanceMintRestricted distance in meters.
ndBeginEndRatiodoubleRatio representing the division of restricted time/distance between the begin and the end.
totalTimeSintTotal time in seconds (sum of unrestricted and restricted times).
totalDistanceMintTotal distance in meters (sum of unrestricted and restricted distances).
isEmptyboolIndicates whether the total time is zero.
isNotEmptyboolIndicates whether the total time is non-zero.
hasRestrictedBeginEndDifferentiationboolIndicates if the begin and end have differentiated restricted values based on the ratio.
restrictedTimeAtBeginintRestricted time allocated to the beginning, based on the ratio.
restrictedTimeAtEndintRestricted time allocated to the end, based on the ratio.
restrictedDistanceAtBeginintRestricted distance allocated to the beginning, based on the ratio.
restrictedDistanceAtEndintRestricted distance allocated to the end, based on the ratio.

Signpost details

Signposts near roadways typically indicate intersections and directions to various destinations. The Maps SDK for Flutter provides realistic image renderings of these signposts, along with additional relevant information.

Below is an example of a rendered signpost details image:

signpost image
Signpost image captured during highway navigation

The SignpostDetails class also provides properties such as:

MemberTypeDescription
backgroundColorColorRetrieves the background color of the signpost.
borderColorColorRetrieves the border color of the signpost.
textColorColorRetrieves the text color of the signpost.
hasBackgroundColorboolIndicates whether the signpost has a background color.
hasBorderColorboolIndicates whether the signpost has a border color.
hasTextColorboolIndicates whether the signpost has a text color.
itemsList<SignpostItem>Retrieves a list of SignpostItem elements associated with the signpost.

Each SignpostItem has the following properties:

MemberTypeDescription
rowintRetrieves the one-based row of the item. Zero indicates not applicable.
columnintRetrieves the one-based column of the item. Zero indicates not applicable.
connectionInfoSignpostConnectionInfoRetrieves the connection type of the item (branch, towards, exit, invalid)
phonemeStringRetrieves the phoneme assigned to the item if available, otherwise empty.
pictogramTypeSignpostPictogramTypeRetrieves the pictogram type for the item (airport, busStation, parkingFacility, etc).
shieldTypeRoadShieldTypeRetrieves the shield type for the item (county, state, federal, interstate, etc)
textStringRetrieves the text assigned to the item, if available.
typeSignpostItemTypeRetrieves the type of the item (placeName, routeNumber, routeName, etc).
hasAmbiguityboolIndicates if the item has ambiguity. Avoid using such items for TTS.
hasSameShieldLevelboolIndicates if the road code item has the same shield level as its road.

The field nextTurnInstruction provides a instruction in text format, suitable for displaying on UI. Please use the onTextToSpeechInstruction callback for getting a instruction suitable for text-to-speech.

Turn Details

The TurnDetails class provides details such as:

  • event: enum containing the turn type. Values for this field include straight, right, left, lightLeft, lightRight, sharpRight, sharpLeft, roundaboutExitRight, roundabout, roundRight, roundLeft, infoGeneric, driveOn, exitNr, exitLeft, exitRight, stayOn and more.
  • abstractGeometryImg: abstract image of the turn (the user needs to verify if the image is valid). The colors might be further personalized with AbstractGeometryImageRenderSettings.
  • roundaboutExitNumber: the roundabout exist number if it exists.

Turn details abstract image vs. turn image:

The difference between images obtained via abstractGeometryImg (left) and turnImg (right) is shown below:

abstract geometry imageturn image
Turn details abstract imageTurn image
  • abstractGeometryImg: Provides a detailed representation of the entire intersection, offering a comprehensive view of the turn geometry. This image can be customized, including options to adjust various colors for better visual alignment with the application's theme.
  • turnImg: Delivers a simplified schematic of the upcoming turn, focusing solely on the essential turn direction. Unlike abstractGeometryImg, this method does not support customization.
tip

Each image is assigned a unique identifier. You can use the uid getter of the images classes to retrieve this id and update the image in the UI only when the ID changes. This strategy can significantly enhance performance during navigation, especially in scenarios where frequent updates might otherwise impact efficiency.

Abstract geometry image customization

The AbstractGeometryImageRenderSettings allows for abstract geometry render settings customization, with the possibility of specifying the colors, improving the overall user experience:

 AbstractGeometryImageRenderSettings customizedRenderSettings = const AbstractGeometryImageRenderSettings(
activeInnerColor: Colors.red,
activeOuterColor: Colors.green,
inactiveInnerColor: Colors.blue,
inactiveOuterColor: Colors.yellow,
);

The render settings from above will create the following image when used:

abstract geometry image
Customized next turn details abstract image

Change the language of the instructions

The texts used in route instructions and related classes follow the language set in the SDK. See Change the SDK language for more details.