Code examples and tutorials for working with Amazon Location Service - Amazon Location Service

Code examples and tutorials for working with Amazon Location Service

This topic shows a list of code examples, tutorials, and blog posts to help you learn about Amazon Location Service. Each code example includes a description of how it works.

You can find additional samples on the AWS Geospatial GitHub page, the AWS samples GitHub page for Amazon Location, and on the AWS blog site.

Note

It is good to understand the difference between the AWS Geospatial GitHub page and the AWS samples GitHub page.

The quick start tutorial is a good place to start before using other samples, as it shows how to complete prerequisites that are useful for most of the samples.

Example availability

Can't find what you need? Request a new code example by using the Provide feedback link at the bottom of this page.

Amazon Location Demo site

You can see demos with source code of Amazon Location Service in action at the Amazon Location Demo site. This site includes a hosted web demo, and also a demo app for Android.

You can also find a wide array of samples, filterable by features, language, and platform in the site's Samples page.

Tutorial: Quick start

There are quick start tutorials available for web, iOS, and Android devices. For each platform, the tutorial shows you how to add an interactive map to an application, and how to make calls to the Amazon Location Service APIs from your application. The tutorial is available for JavaScript in a static webpage, Kotlin for an Android phone application, or Swift for an iOS application.

Tutorial: Database enrichment

This tutorial shows you how to use Amazon Location Service, called from AWS Lambda to normalize addresses and add latitude and longitude to records in an Amazon Aurora database. Uses Amazon Aurora and AWS Lambda.

Documentation link: Amazon Aurora PostgreSQL user-defined functions for Amazon Location Service

Example: Explore app

One of the best ways to learn about the functionality of Amazon Location Service is to use the Explore functionality within the Amazon Location console. This full web application example mimics the maps, places, routes, geofences, and trackers functionality from the console to show you how to recreate these features in your own app. Uses Amplify, React, and JavaScript.

Samples GitHub link: Explore sample application

Example: Style a map

This code example shows how to switch between a satellite map and a vector road map, using MapLibre in JavaScript. Uses MapLibre, the Amazon Location authentication helper, and JavaScript.

Geospatial GitHub link: Interactive map with style switching

Example: Draw markers

This code example shows Amazon Locker locations in Vancouver, BC, Canada. It shows how to draw markers at point locations. Uses MapLibre, Node.js, React, the Amazon Location authentication helper and JavaScript.

Geospatial GitHub link: Interactive map with markers at points

Example: Draw clustered points

Using USGS earthquake data, this code example shows how to draw points that cluster together when they are close together on the map. Uses MapLibre, Node.js, React, Amplify, and JavaScript.

Samples GitHub link: Interactive map with clusters of points

Example: Draw a polygon

This code example shows how to draw a polygon on the map. Uses MapLibre, Node.js, React, the Amazon Location authentication helper, and JavaScript.

Geospatial GitHub link: Interactive map with polygons

Example: Change the map language

This code example shows how you can change the display language of maps in Amazon Location. Uses Amplify, React, and MapLibre.

Samples GitHub link: Change Map Language Sample

Blog: Estimated delivery time notifications

This blog post shows different ways to notify customers with estimated delivery times. It explains using routes to show estimated driving time, and then using trackers and geofences to notify when a driver gets close to the customer. Uses Amplify, React, Amazon EventBridge, and Amazon Simple Notification Service (Amazon SNS).

Blog link: Estimated Time of Arrival and Proximity Notifications

Example: Stream Position Updates

Kinesis Stream To Tracker App: This sample demonstrates how to use Kinesis Data Stream to post tracker updates with Amazon Location Service. The sample is a deployable lambda application written in python that can be integrated with a Kinesis Data Stream to consume the Kinesis events and batch update device positions.

Repository link: Amazon Location Amazon Kinesis Data Streams Stream To Tracker App

For more information on tracking and geofences, see the Geofences and Trackers documentation. Developers can deploy the app by following the AWS's Serverless Application Repository documentation, or dicretly from the Lambda console.

Device Position Streaming Sample App: This code example shows how to stream device position data to a Kinesis Data Stream and how geofence notifications work. This app depends on the Kinesis Stream to Tracker Sample App, listed above, to be running for the streamed tracker positions to be updated in Amazon Location Service.

Repository link: Amazon Location Device Position Streaming Sample App

Example: Geofencing and Tracking mobile application

This sample application shows how a tracker and geofence interact using a combination of Lambda, AWS IoT and Amazon Location features. There are tutorials avaible for iOS and Android.

Tutorial link: Sample Geofence and Tracker mobile application