Prerequisites for calculating routes using Amazon Location
This page outlines prerequisites to get started with the service's routing features, which enable you to calculate optimized routes and travel times between multiple locations. It covers essential topics, such as configuring access permissions, setting up the required resources within your AWS account, and any additional dependencies or tools needed based on your specific use case or development environment.
Create a route calculator resource
Before you can calculate a route, create a route calculator resource in your AWS account.
When you create a route calculator resource, you can choose from the data providers available:
-
Esri – For more information about Esri's coverage in your region of interest, see Esri details on street networks and traffic coverage
. -
HERE Technologies – For more information about HERE's coverage in your region of interest, see HERE car routing coverage
and HERE truck routing coverage . -
Grab – For more information about Grab's coverage, see Countries/regions and area covered.
Note
If your application is tracking or routing assets you use in your business, such
as delivery vehicles or employees, you must not use Esri as your geolocation
provider. See section 82 of the AWS
service terms
You can do this using the Amazon Location Service console, the AWS CLI, or the Amazon Location APIs.
To create a route calculator resource using the Amazon Location console
-
Open the Amazon Location console at https://console.aws.amazon.com/location/
. -
In the left navigation pane, choose Route calculators.
-
Choose Create route calculator.
-
Fill out the following boxes:
-
Name – Enter a name for the route calculator resource. For example,
ExampleCalculator
. Maximum 100 characters. Valid entries include alphanumeric characters, hyphens, periods, and underscores. -
Description – Enter an optional description.
-
-
For Data providers, choose a data provider
to use as a route calculator. -
(Optional) Under Tags, enter a tag Key and Value. This adds a tag your new route calculator resource. For more information, see Tagging your resources.
-
Choose Create route calculator.
Note
Billing depends on your usage. You may incur fees for the use of other AWS
services. For more information, see Amazon Location Service
pricing
Authenticating your requests
Once you create a route calculator resource and you're ready to begin building location features into your application, choose how you would authenticate your requests:
-
To explore ways you can access the services, see Accessing Amazon Location Service.
-
If you have a website with anonymous users, you may want to use API Keys or Amazon Cognito.
Example
The following example shows using an API key for authorization, using AWS JavaScript SDK v3
, and the Amazon Location JavaScript Authentication helper. import { LocationClient, CalculateRouteCommand } from "@aws-sdk/client-location"; import { withAPIKey } from "@aws/amazon-location-utilities-auth-helper"; const apiKey = "
v1.public.your-api-key-value
"; // API key // Create an authentication helper instance using an API key const authHelper = await withAPIKey(apiKey); const client = new LocationClient({ region: "<region>
", // region containing Cognito pool ...authHelper.getLocationClientConfig(), // Provides configuration required to make requests to Amazon Location }); const input = { CalculatorName: "ExampleCalculator
", DeparturePosition: [-123.4567, 45.6789], DestinationPosition: [-123.123, 45.234], }; const command = new CalculateRouteCommand(input); const response = await client.send(command);