It’s hard to imagine a modern world without digital maps.
Almost all the technical giants like Google or Apple have their own solution in the digital mapping industry.
Amazon decided to join them and last year provided AWS Location Service.
AWS Location Service is a location-based service that developers can use to add geospatial data and location functionality to applications.
Customers can visualize data on a map, recommend routes, use geocoding to convert plain text addresses into geographic coordinates, use reverse geocoding to convert latitude and longitude coordinates into addresses, and monitor and track assets such as fleets of vehicles.
Let’s try to implement a test use case where you get notification when somebody enters the specific area using AWS Location Service.
Step 1: Create a geofence
Geofence is a set of coordinates where we indicate a zone around the delivery address.
For this purpose we use geojson.io.
Also you can use the Amazon Location interactive tool.
Save output as a json file.
In the Amazon Location console, open the Geofence collections page and create a new one.
In the created geofence collection add our coordinates.
Step 2: Create a tracker
Now we will create a tracker that gets location updates.
In the Amazon Location console, open the Trackers and create our tracker with default parameters.
Then link this tracker to our geofence collection.
Step 3: Set up notification
To get notification when a driver enters the geofence we have to use Amazon Simple Notification Service (SNS).
In the Amazon SNS console, open Topics and create standart topic.
In the topic create a subscription with Email protocol and enter your email address.
After creation of subscription you will get a confirmation message by email.
Step 4: Create a Lambda function
In this step we create a lambda function that sends notification when the delivery driver enters the area.
import jsonimport boto3sns_client = boto3.client('sns')def lambda_handler(event, context): print(event) topicArn = 'arn:aws:sns:us-east-1:acct-num:delivery-topic' subject = 'Geofence notification' message = 'Your delivery is within the area, you should receive it soon!' response = sns_client.publish( TopicArn=topicArn, Subject=subject, Message=message, MessageAttributes={"email" : { "DataType":"String", "StringValue":"mruletkin6@gmail.com"}}) return { 'statusCode': 200, 'body': json.dumps('Success!') }
Build Smarter Location-Aware Applications with AWS
Our AWS-certified engineers can help you design, integrate, and optimize geofencing, real-time tracking, and location-based solutions using AWS Location Service.
This one will trigger the ENTER event of the geofence and the EventBridge rule we created in the previous step will detect the event and trigger SNS notification:
AWS Location Service is a managed service that allows developers to add maps, geocoding, tracking, and geofencing to applications without managing complex geospatial infrastructure. It’s commonly used for delivery tracking, fleet management, logistics, and real-time location-based notifications.
How does geofencing work in AWS Location Service?
Geofencing in AWS Location Service works by defining a virtual boundary (geofence) around a real-world location. When a device or asset with a tracker enters or exits this boundary, an event is triggered. This event can be processed through Amazon EventBridge or AWS Lambda to send alerts, automate workflows, or update applications in real time.
Can AWS Location Service integrate with AWS Lambda?
Yes. AWS Lambda can be integrated with AWS Location Service to automate actions when geofence events occur. For example, you can trigger a Lambda function to send a push notification or publish a message to Amazon SNS whenever a device enters or exits a defined geofence.
What are the benefits of using AWS Location Service over third-party mapping APIs?
Unlike third-party APIs, AWS Location Service offers native integration with the AWS ecosystem, strong data privacy controls, and cost optimization through usage-based pricing. It allows companies to build secure and scalable geolocation solutions while keeping sensitive location data within AWS infrastructure.
Conclusion
In this article we walked through the steps of creating applications for getting notifications using Amazon Location SDK for Python (boto3).
Use case we implemented showed us a small part of AWS Location Service functionality.
To summarize it’s an important service that enables customers to create complex decisions using holistic AWS infrastructure that allows them to optimize the development process and costs.
Cut AWS costs without compromising quality
Up to 40% savings with serverless solutions, audits, and Well-Architected Reviews.