Announcing new APIs for Amazon Location Service Routes, Places, and Maps | Amazon Web Services

Voiced by Polly

Amazon Location Service today released 17 new and improved APIs that extend and improve the capabilities of Routes, Places, and Maps, creating a more cohesive and efficient developer experience. By introducing improved features and offering simplified migration, these updates are more accessible and useful for a wide range of applications.

You now have access to advanced route optimization, toll cost calculations, GPS route capture and a range of map styles with static and dynamic rendering options, and you can perform proximity-based searches and predictive suggestions with rich and detailed POI information.

At Amazon, the vast majority of our plans are driven by customer feedback. Many customers building apps using Amazon Location Service have shared that they need purpose-built APIs and more granular details like contact information and business hours when working with location-based data. While the current set of APIs has provided many customers with valuable tools, developers have expressed a desire for additional features such as detailed route planning, proximity-based search, additional location details, and static map images. These new APIs address these requirements and provide a more comprehensive placement solution out of the box.

New and improved abilities
Today’s launch features 10 updated APIs and seven brand new APIs that respond directly to your feedback. Each service—routes, places, and maps—receives specific enhancements designed to support a wider range of use cases.

Road
The Amazon Location Routes API now supports advanced route planning and customization capabilities that allow users to:

  • CalculateIsolines to identify service areas within a specific travel time or distance
  • OptimizeWaypoints to determine the most efficient sequence of waypoints to help minimize travel time or distance
  • Calculate toll costs to get accurate cost estimates for routes involving toll roads
  • SnapToRoadsenabling accurate comparison of GPS routes by attaching points to the road network

With these options, you can design more accurate and dynamic routes for your users. For example, a logistics company could optimize drivers’ routes in real time, take current traffic into account and minimize travel costs for deliveries.

Maps
The updated Amazon Location Maps API includes more purpose-built map styles created by expert cartographers. These map styles offer professional designs that speed time to market and eliminate the need to create custom maps. Additionally, the Static Map Image feature allows developers to integrate static maps into applications, reducing the need for continuous data streaming and improving performance in use cases where interactivity is not required.

Key features of the Maps API include:

  • GetTileto download a tile from a tile set with the specified X, Y, and Z axis values
  • GetStyleDescriptorto return style information
  • GetStaticMapwhich allows rendering of non-interactive maps for reporting or visualization purposes

Seats
Improvements to the Amazon Location Places API enable more granular search capabilities and address requests for increased granularity in location data. New abilities include:

  • SearchNearby and Autocompletewhich support proximity-based queries and enable predictive text functions for a better user experience
  • Improved business details with categories such as hours of operation, contact information and other attributes for points of interest

These features are especially useful for applications where users need detailed information about nearby locations, such as food delivery services or retail applications. Imagine a customer opens a food delivery app and uses it to search for nearby restaurants SearchNearbyand retrieves restaurant details such as hours and contact information to confirm availability. Once a driver is assigned multiple delivery orders, the app will use OptimizeWaypoints suggest the most efficient route for pickup and delivery. When the driver follows the road, SnaptoRoads it provides accurate visualization of their location, improving the customer’s real-time tracking experience.

Improved location service in action
Calling the API is simple. You can use the AWS Command Line Interface (AWS CLI), one of our AWS SDKs, or a simple REST API. However, displaying information on the map in a web or mobile application requires additional settings. Although this process is well documented, it is too detailed to fully cover here. In this demo I will focus on using the API.

Amazon Location Service allows API calls to be authenticated in two ways: through AWS API authentication (AWS Sigv4 authentication) or through API keys. API keys may be more convenient for mobile application developers where the end user is not authenticated or when integration with Amazon Cognito is not feasible. This is the recommended authentication method for front-end applications.

To demonstrate the versatility of the API and how easily you can integrate it into your applications, I use a combination of the AWS CLI, cURL, and a graphical REST API client for each step of the demo.

Step 1: Create an API key

First, I create an API key for my application using the AWS CLI. You can also manage API keys in the AWS Management Console.

REGION=eu-central-1
KEYNAME=geo-key-seb

aws location create-key --region ${REGION} --key-name ${KEYNAME} --restrictions \
AllowActions="geo-routes:*","geo-places:*","geo-maps:*",\
AllowResources="arn:aws:geo-routes:${REGION}::provider/default",\
"arn:aws:geo-places:${REGION}::provider/default",\
"arn:aws:geo-maps:${REGION}::provider/default" \
--no-expiry 

{
    "Key": "v1.public.ey...cy",
    "KeyArn": "arn:aws:geo:eu-central-1:02345678901:api-key/geo-key-seb",
    "KeyName": "geo-key-seb",
    "CreateTime": "2024-09-29T09:35:53.115000+00:00"
}

This command will generate an API key that I can now use to call the Amazon Location API.

Step 2: Get geographic coordinates

I continue to use cURL get geographic coordinates (longitude and latitude) for the city center of Lille, France by calling GeoCode and forwarding the address in QueryText parameter.parameter.

$ curl --silent -X "POST" "https://places.geo.eu-central-1.amazonaws.com/v2/geocode?key=v1.public.ey...cy" \
       -d $'{ "QueryText": "Grand Place, Lille, France" }' 
 
{"ResultItems":({"PlaceId":"AQ...5U","PlaceType":"Street","Title":"Grand'Place, 59800 Lille, France",
                 "Address":{"Label":"Grand'Place, 59800 Lille, France",
                 "Country":{"Code2":"FR","Code3":"FRA","Name":"France"},
                 "Region":{"Code":"HDF","Name":"Hauts-de-France"},"SubRegion":{"Name":"Nord"},
                 "Locality":"Lille","District":"Centre","PostalCode":"59800",
                 "Street":"Grand'Place","StreetComponents":({"BaseName":"Grand'Place","Language":"fr"})},
                 "Position":(3.06361,50.63706),
                 "MapView":(3.0628,50.6367,3.06413,50.63729),
                 "MatchScores":{"Overall":1,"Components":{"Address":{"Country":1,"Locality":1,"Intersection":(1)}}}})}

This will return several data points, including the GPS coordinates for the city center: (3.06361, 50.63706).

Step 3: Search for places nearby

Using the obtained coordinates, I use the REST API client tool to make calls SearchNearby API for finding interesting places around Lille city center.

Amazon Location Service - API calls for places of interest

On the right side of the screen I can read the API response: a list of nearby places such as restaurants, banks and parking lots. I can further refine the search by entering categories or limiting the search area.

Tea SearchNearby The API accepts optional Filter parameter to help you limit your search within a bounding box or include or exclude store chains, categories, countries, or food types.

"Filter": {
   "BoundingBox": ( number ),
   "ExcludeBusinessChains": ( "string" ),
   "ExcludeCategories": ( "string" ),
   "ExcludeFoodTypes": ( "string" ),
   "IncludeBusinessChains": ( "string" ),
   "IncludeCategories": ( "string" ),
   "IncludeCountries": ( "string" ),
   "IncludeFoodTypes": ( "string" )
},

In my search for interesting places nearby, one of the results returned was McDonald’s, a well-known international reference 🍔.

Amazon Location Service - Nearby search result

Step 4: Get driving directions

Finally, I use the AWS CLI to calculate driving routes between two city centers: Brussels, Belgium and Lille, France.

aws location calculate-routes    \
    --origin 4.35278 50.84687      \
    --destination 3.06361 50.63706 \
    --key "v1.public.ey...cy"

The answer contains a curve for plotting the route on the map and a detailed list of driving routes.

...
          "TravelMode": "Car",
          "Type": "Vehicle",
          "VehicleLegDetails": {
            "TravelSteps": (
              {
                "Duration": 15,
                "Distance": 75,
                "ExitNumber": (),
                "GeometryOffset": 0,
                "Type": "Depart"
              },
              {
                "Duration": 10,
                "Distance": 8,
                "ExitNumber": (),
                "GeometryOffset": 2,
                "Type": "Turn",
                "TurnStepDetails": {
                  "Intersection": (),
                  "SteeringDirection": "Right",
                  "TurnIntensity": "Typical"
                }
              },
...

Step 5: View the driving route on the map

To visualize the route on the map, I use the MapLibre library, which is a rendering engine for displaying maps in web and mobile applications. Following the Amazon Location Service Developer Guide, I created a basic app to display a route.

Amazon Location Service - Map with route

In addition to MapLibre, you can use AWS Amplify to integrate and display Amazon Location data in your applications.

We’re getting started
With these new and updated APIs, Amazon Location Service offers a more comprehensive set of map and location data for your business needs. These will help accelerate your development lifecycle by increasing developer agility and scalability.

To get started, explore the updated Amazon Location Service Developer Guide and start integrating these features today. You can also visit the Amazon Location Service page to learn more or try out the API with your favorite AWS SDKs to see how they can enhance your applications.

— self

Leave a Comment