Skip to main content
APIs 5 min read

HERE Routing on Amazon Location Service

HERE Truck Routing AWS

HERE provides Amazon Location Service with map rendering, geocoding, search, and routing, with global coverage and local flavor that transect geographic borders. Previously, we discussed HERE Maps on Amazon Location Service and HERE Geocoding and Search on Amazon Location Service. In this blog, we will discuss the Routes feature in Amazon Location Service using accurate, fresh, and robust data from HERE Technologies. 

With Amazon Location Routes, the application can request the travel time, distance, and directions between a departure point and one or more destinations, with specific travel restrictions such as Truck mode, vehicle dimension, and avoidances. Amazon Location Service provides routing data sourced from HERE. This enables the application to obtain accurate estimates of travel time based on up-to-date roadway information and live traffic information. Amazon Location Service Routes can help you achieve business goals such as faster delivery and reduced fuel consumption.

HERE Routing


Route options

  • Support for different transportation modes: car, truck, pedestrian

  • Options for the fastest route, avoid road types (e.g., highways, toll roads) 

Traffic-enabled routing

  • Routes based on real-time and/or historical traffic data

  • Time-aware routes based on time of day, time of the year 

  • Incident-aware routes based on traffic accidents, construction, etc.

Truck routing

  • Support for all physical restrictions 

  • Truck profiles: height, length, width, and weight.

  • Avoid U-turns and difficult maneuvers.

For the purpose of showcasing and exploring the capabilities of HERE Routing on Amazon Location Service, we have created a demo application below that uses Amplify UI Georeact-map-gl and Amazon Location Service. This application is extended and modified from this Amazon Location sample. In this application, you can plot route positions on the map to calculate a route, you can also choose the travel mode (car, truck or walking) and the departure time to determine the route based on traffic data. 

Now let's look at how we built and customized this demo application.

  • We created a route calculator resource and identity pool for authentication in the Amazon Location Service console as prerequisites before we begin geocoding, reverse geocoding, or searching for places. And don't forget to choose HERE as the data provider. 
create route calculator index
  • To showcase the benefit of HERE as data provider, we set the center of the map in the Greater Los Angeles area and chose to use HERE Explore Truck map style that highlights track restrictions and attributes (including width, height, and HAZMAT) with symbols and icons, to support use cases within transport and logistics. Check out HERE Maps on Amazon Location Service blog for more details on other map styles. 
          initialViewState={{ // Greater Los Angeles
            longitude: -117.651215,
            latitude: 34.068871,
            zoom: 9,
          mapStyle="here.explore.truck" // HERE Explore Truck map style
  • We also removed other functionalities such as geofencing and tracking from the sample application to only show the routing capabilities. Below is the code snippet that takes the routing parameters and calls the routing service. 
        // Get calculated route result
const callCalculateRouteCommand = async (client, markers, options) => {
  if (client && markers.length > 1) {
    const command = new CalculateRouteCommand({
      CalculatorName: ROUTE,
      IncludeLegGeometry: true,
      DeparturePosition: markers[0].coordinates,
      DestinationPosition: markers[markers.length - 1].coordinates,
      WaypointPositions: markers.length > 2 ? markers.slice(1, -1).map((marker) => marker.coordinates) : undefined,
      TravelMode: options.travelMode,
      DepartNow: options.departureTimeMode === "now" ? true : false,
      DepartureTime: options.departureTimeMode === "future" ? options.departureDateTime : undefined,

    return client.send(command);
  } else {
    alert("Set a departure and destination point on the map before calculating the route.");

  • The above code will make a request to the routing service end point with these parameters below for a truck route from Long Beach to Fontana, California. 
  • And below is the sample JSON response from the routing service  on the request for a truck route from Long Beach to Fontana, California
	"Legs": [{
		"StartPosition": [-118.1963885, 33.7668755],
		"EndPosition": [-117.4343767, 34.1037471],
		"Distance": 101.964,
		"DurationSeconds": 4800,
		"Geometry": {
			"LineString": [
				[-118.196389, 33.766876],
                //.. more LineStrings
				[-117.434377, 34.103747]
		"Steps": [{
			"StartPosition": [-118.196389, 33.766876],
			"EndPosition": [-118.1964, 33.76718],
			"Distance": 0.034,
			"DurationSeconds": 23,
			"GeometryOffset": 0
		//... more Steps		  
			"StartPosition": [-117.43441, 34.10287],
			"EndPosition": [-117.434377, 34.103747],
			"Distance": 0.098,
			"DurationSeconds": 21,
			"GeometryOffset": 1962
	"Summary": {
		"RouteBBox": [-118.20878, 33.7668755, -117.43436, 34.1037471],
		"DataSource": "Here",
		"Distance": 101.964,
		"DurationSeconds": 4800,
		"DistanceUnit": "Kilometers"

I hope that you can use this demo application to explore HERE Routing capabilities on Amazon Location Service. To learn more about other functionalities, please check out this developer guide on Amazon Location Service. 

Erwin Soekianto

Erwin Soekianto

Developer Evangelist

Have your say

Sign up for our newsletter

Why sign up:

  • Latest offers and discounts
  • Tailored content delivered weekly
  • Exclusive events
  • One click to unsubscribe