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
Note
It is good to understand the difference between the AWS Geospatial GitHub page and the AWS samples GitHub page.
-
Geospatial GitHub – The AWS Geospatial GitHub page
includes samples that are created and maintained by the Amazon Location Service team. -
Samples GitHub – The AWS samples GitHub page for Amazon Location
includes samples that were created for Amazon Location, but may or may not be actively maintained.
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.
Topics
- Amazon Location Demo site
- Tutorial: Quick start
- Tutorial: Database enrichment
- Example: Explore app
- Example: Style a map
- Example: Draw markers
- Example: Draw clustered points
- Example: Draw a polygon
- Example: Change the map language
- Blog: Estimated delivery time notifications
- Example: Stream Position Updates
- Example: Geofencing and Tracking mobile application
Amazon Location Demo site
![](/images/location/latest/developerguide/images/samples/location-demo-site-samples.png)
You can see demos with source code of Amazon Location Service in action at the Amazon Location Demo site
You can also find a wide array of samples, filterable by features, language, and
platform in the site's Samples
Tutorial: Quick start
![](/images/location/latest/developerguide/images/samples/quickstart-both.png)
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.
-
JavaScript for a static webpage documentation link: Creating a web app
Kotlin for an Android application documentation link: Quick start with Amazon Location Service
Swift for an iOS app documentation link: Creating an iOS app
Tutorial: Database enrichment
![](/images/location/latest/developerguide/images/samples/database-validation_small.png)
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
![](/images/location/latest/developerguide/images/samples/ExploreSample_small.png)
One of the best ways to learn about the functionality of Amazon Location Service is to use the Explore functionality
Samples GitHub link: Explore sample application
Example: Style a map
![](/images/location/latest/developerguide/images/samples/map-styles-both_small.png)
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
![](/images/location/latest/developerguide/images/samples/markers_small.png)
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
![](/images/location/latest/developerguide/images/samples/clusters_small.png)
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
![](/images/location/latest/developerguide/images/samples/polygons_small.png)
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
![](/images/location/latest/developerguide/images/samples/language-japanese_small.png)
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
![](/images/location/latest/developerguide/images/samples/proximity-notifications_small.png)
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
![](/images/location/latest/developerguide/images/samples/sampleappgeofenceKVS1.png)
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