

# Code examples and tutorials for working with Amazon Location Service
<a name="samples"></a>

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](https://github.com/orgs/aws-geospatial/repositories), the [AWS samples GitHub page for Amazon Location](https://github.com/aws-samples/amazon-location-samples), and on the [AWS blog site](https://aws.amazon.com/blogs/mobile/category/mobile-services/amazon-location/).

**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](https://github.com/orgs/aws-geospatial/repositories) includes samples that are created and maintained by the Amazon Location Service team.
**Samples GitHub** – The [AWS samples GitHub page for Amazon Location](https://github.com/aws-samples/amazon-location-samples) includes samples that were created for Amazon Location, but may or may not be actively maintained.

The [quick start](sample-quick-start.md) 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](sample-demo-site.md)
+ [Tutorial: Quick start](sample-quick-start.md)
+ [Tutorial: Database enrichment](example-validate-database.md)
+ [Example: Explore app](example-explore.md)
+ [Example: Style a map](example-switch-styles.md)
+ [Example: Draw markers](example-draw-markers.md)
+ [Example: Draw clustered points](example-draw-clusters.md)
+ [Example: Draw a polygon](example-draw-polygon.md)
+ [Example: Change the map language](example-map-language.md)
+ [Blog: Estimated delivery time notifications](example-delivery-notifications.md)
+ [Example: Stream Position Updates](example-stream-position-updates.md)
+ [Example: Geofencing and Tracking mobile application](example-tracking-geofencing.md)

# Amazon Location Demo site
<a name="sample-demo-site"></a>

![\[alt text not found\]](http://docs.aws.amazon.com/location/previous/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](https://location.aws.com/). This site includes a [hosted web demo](https://location.aws.com/demo), and also a demo app for [Android](https://play.google.com/store/apps/details?id=com.aws.amazonlocation).

You can also find a wide array of samples, filterable by features, language, and platform in the site's [Samples](https://location.aws.com/samples) page.

# Tutorial: Quick start
<a name="sample-quick-start"></a>

![\[alt text not found\]](http://docs.aws.amazon.com/location/previous/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: [Create a web app to use Amazon Location Service](qs-web.md)
+ Kotlin for an Android application documentation link: [Quick start with Amazon Location Service](getting-started.md)
+ Swift for an iOS app documentation link: [Create an iOS app for Amazon Location Service](qs-ios.md)

# Tutorial: Database enrichment
<a name="example-validate-database"></a>

![\[alt text not found\]](http://docs.aws.amazon.com/location/previous/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](database-address-validation.md)

# Example: Explore app
<a name="example-explore"></a>

![\[alt text not found\]](http://docs.aws.amazon.com/location/previous/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](https://console.aws.amazon.com/location/explore/home) 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](https://github.com/aws-samples/amazon-location-samples/tree/main/amplify-ui-geo-explore)

# Example: Style a map
<a name="example-switch-styles"></a>

![\[alt text not found\]](http://docs.aws.amazon.com/location/previous/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](https://github.com/aws-geospatial/amazon-location-samples-js/tree/main/map-style-change)

# Example: Draw markers
<a name="example-draw-markers"></a>

![\[alt text not found\]](http://docs.aws.amazon.com/location/previous/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](https://github.com/aws-geospatial/amazon-location-samples-react/tree/main/map-with-markers)

# Example: Draw clustered points
<a name="example-draw-clusters"></a>

![\[alt text not found\]](http://docs.aws.amazon.com/location/previous/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](https://github.com/aws-samples/amazon-location-samples/tree/main/react-map-gl-clusters)

# Example: Draw a polygon
<a name="example-draw-polygon"></a>

![\[alt text not found\]](http://docs.aws.amazon.com/location/previous/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](https://github.com/aws-geospatial/amazon-location-samples-react/tree/main/map-with-geojson)

# Example: Change the map language
<a name="example-map-language"></a>

![\[alt text not found\]](http://docs.aws.amazon.com/location/previous/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](https://github.com/aws-samples/amazon-location-samples/tree/main/react-map-gl-change-map-language?)

# Blog: Estimated delivery time notifications
<a name="example-delivery-notifications"></a>

![\[alt text not found\]](http://docs.aws.amazon.com/location/previous/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](https://aws.amazon.com/blogs/mobile/implementing-estimated-time-of-arrival-and-proximity-notifications-for-delivery-using-amazon-location-service/)

# Example: Stream Position Updates
<a name="example-stream-position-updates"></a>

![\[alt text not found\]](http://docs.aws.amazon.com/location/previous/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](https://github.com/aws-geospatial/amazon-location-stream-device-data-to-tracker-lambda)

For more information on tracking and geofences, see the [Geofences and Trackers](https://docs.aws.amazon.com/location/previous/developerguide/geofence-tracker-concepts.html) documentation. Developers can deploy the app by following the [AWS's Serverless Application Repository](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/serverlessrepo-how-to-consume.html) documentation, or dicretly from the [Lambda console](https://console.aws.amazon.com/lambda/home#/create/app?applicationId=arn:aws:serverlessrepo:us-east-1:003883091127:applications/kinesis-stream-device-data-to-amazon-location-tracker).

**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](https://github.com/aws-geospatial/amazon-location-samples-react/tree/main/tracking-data-streaming)

# Example: Geofencing and Tracking mobile application
<a name="example-tracking-geofencing"></a>

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](https://docs.aws.amazon.com//location/previous/developerguide/geofence-tracking-tutorials.html)