Alternative routes with route labels
The alternative
parameter instructs the service to find any available alternative routes. Also, with the routeLabels
parameter, you can request the route to be labelled. A list of the most important names and route numbers on this route that differentiate it from other alternatives is then used to generate labels.
Each route will have no more than two labels. The first label is the longest road on the route, and the second one is the next longest "non-common" road. Non-common means that this road hasn't been used for labeling other routes in response. If the road takes two-thirds or more of the total route length, it might be only one label for such a route.
The routeLabels
data in response is useful for constructing labels for different routes in UI, for example, "main road via A10", "alternative route via A10, B273".
curl -X GET 'https://router.hereapi.com/v8/routes?origin=52.534647%2C13.286891&destination=52.53329%2C13.47486&return=routeLabels,summary&transportMode=car&lang=en-gb&alternatives=1&apikey={YOUR_API_KEY}'
{
"routes" : [
{
"id" : "20d89644-f7f0-4fc6-811d-3efd4545d036",
"routeLabels" : [
{
"label_type" : "Name",
"name" : {
"language" : "de",
"value" : "Seestraße"
}
},
{
"label_type" : "Name",
"name" : {
"language" : "de",
"value" : "Stadtring Berlin"
}
}
],
"sections" : [
{
"arrival" : {
"place" : {
"location" : {
"lat" : 52.5334674,
"lng" : 13.4745833
},
"originalLocation" : {
"lat" : 52.53329,
"lng" : 13.4748599
},
"type" : "place"
},
"time" : "2022-09-19T16:21:26+02:00"
},
"departure" : {
"place" : {
"location" : {
"lat" : 52.5341366,
"lng" : 13.2871219
},
"originalLocation" : {
"lat" : 52.534647,
"lng" : 13.286891
},
"type" : "place"
},
"time" : "2022-09-19T15:50:52+02:00"
},
"id" : "1b4ce9e1-96eb-44d6-aae7-e5ab63b8dce7",
"summary" : {
"baseDuration" : 1834,
"duration" : 1834,
"length" : 16273
},
"transport" : {
"mode" : "car"
},
"type" : "vehicle"
}
]
},
{
"id" : "c34a0003-c55f-4100-b909-79fc88450847",
"routeLabels" : [
{
"label_type" : "Name",
"name" : {
"language" : "de",
"value" : "Danziger Straße"
}
},
{
"label_type" : "Name",
"name" : {
"language" : "de",
"value" : "Seestraße"
}
}
],
"sections" : [
{
"arrival" : {
"place" : {
"location" : {
"lat" : 52.5334674,
"lng" : 13.4745833
},
"originalLocation" : {
"lat" : 52.53329,
"lng" : 13.4748599
},
"type" : "place"
},
"time" : "2022-09-19T16:21:57+02:00"
},
"departure" : {
"place" : {
"location" : {
"lat" : 52.5341366,
"lng" : 13.2871219
},
"originalLocation" : {
"lat" : 52.534647,
"lng" : 13.286891
},
"type" : "place"
},
"time" : "2022-09-19T15:50:52+02:00"
},
"id" : "f736b1a1-87f1-4b9f-b7ac-382cbf8f7bc7",
"summary" : {
"baseDuration" : 1865,
"duration" : 1865,
"length" : 16269
},
"transport" : {
"mode" : "car"
},
"type" : "vehicle"
}
]
}
]
}