5 Popular Scenarios for Integrating Location Services

If you are a developer working with Amazon Web Services (AWS) and looking to integrate maps and location data, I’ll show you in this post five popular scenarios you can integrate HERE Location Services with the AWS platform. scenarios

At the end of this post, you will find an on-demand video discussing these in more detail. Let’s go!

Related:- 6 Ways Small Businesses Can Fight Climate Change

1. Web Sites

Amazon has many options for developers to create/host a website as shown in this screen capture:

Perhaps the most common use of location services is with a visual, interactive map seen on a web page. This is possible with our Maps API for JavaScript. Alternatively, web applications could also retrieve map images via API, as well as other location services.

2. Serverless

Hosting and maintaining business logic with a serverless architecture is possible with AWS Lambdas. You could write your own serverless process from scratch, use a “blueprint”, or select from one of many in the AWS Serverless Repository. If you want to create your own custom location services API wrapper, you could choose from what HERE offers in the repository as shown here:

3. AWS IoT

With so many IoT devices out there, this has become a very popular scenario for using location services. AWS IoT provides the means to managing all those devices supporting your solution. HERE contributes with the integration of location services to help you track devices, create routes, and discover location information. HERE also provides integration for the various client types with our SDKs.

Related:-10 of the Most Profitable Small Businesses

4. AWS Lex

If automation with chat bots intrigues you, AWS Lex makes it easy to create one! And if you need to integrate location data in your conversational UX, simply use our APIs in the Lambda function which fulfills the processing of the chat bot. The screen capture below shows a simple chat bot configured to use a Lambda containing the needed API call to determine if an asset is in an area (geofencing).

5. Alexa

Voice interaction is more popular than ever before. Developers can target Alexa by creating skills that allow voice commands. When such skills require location services, this can be accomplished once again with simple API calls.


In this post, we briefly covered five popular scenarios where AWS developers could integrate HERE Location Services.

Geolocation in web applications: What it does

After developing a web app, there are various uses of geolocation. Like for statistical purposes and special cases like dynamically changing a user’s language when he/she migrates. Geolocation is a method of guessing a user’s location by looking at his/her IP address.


The IP address and geolocation

The IP addresses are the telephone numbers of the world wide web. They are usually a set of numbers separated by dots. An example is 212.45.683.23. Institutions obtain IP addresses in blocks. A particular IP address with 45.160, in the beginning, is one out of the IP address block belonging to Brazil. Pretty sure, this user is living somewhere in Brazil. Even more, IP address blocks are sold, transferred and reallocated due to various factors.

Methods to implement IP based geolocation

Commercial institutions like MaxMind provide large databases that map IP addresses at different levels of granularity (city, state, country of residence). One can download the database at a one time fee. However, as stated above, IP address blocks change configurations frequently. So in order to maintain accuracy, one has to pay MaxMind for weekly or monthly database updates. You have to put technical effort to integrate the database and update it regularly (weekly/monthly).

Another option is to use a commercial service that offers geolocation as a service. You have your own web app, you send your visitor’s IP address to the API of the service. The service then replies with the visitor’s location and you can particularly customize the visitor’s experience.

Related:-Windows 10 now has over 1 billion active users

A basic Python program featuring geolocation

Here is a Python web application written in the Flask web framework:

from flask import Flask 
from flask import request

import requests

app = Flask(__name__)

def get_country(ip_address):
        response = requests.get("http://ip-api.com/json/{}".format(ip_address))
        js = response.json()
        country = js['countryCode']
        return country
    except Exception as e:
        return "Unknown"

def home():
    ip_address = request.remote_addr
    country = get_country(ip_address)
    # number of countries where the largest number of speakers are French
    # data from http://download.geonames.org/export/dump/countryInfo.txt
    if country in ('BL', 'MF', 'TF', 'BF', 'BI', 'BJ', 'CD', 'CF', 'CG', 'CI', 'DJ', 'FR', 'GA', 'GF', 'GN', 'GP', 'MC', 'MG', 'ML', 'MQ', 'NC'):
        return "Bonjour"
    return "Hello"

if __name__ == "__main__":

Let’s break down what it does and how it works:

  1. We import the main Flask module, which initializes our script as a web application. We also import the request module from Flask, which will allow us to get various data about our visitors, including their IP address.
  2. The request module we imported above handles the client connection requests (with an s), it is a completely different library that allows our server to make HTTP calls to third-party services. We’ll use this later to call the ip-api service.
  3. We initialize the app variable as a Flask web application and call app.run() right at the end of the script to make Flask listen for visitors and serve the web pages.
  4. The get_country function takes in an IP address, calls the ip-api service and extracts the ISO two-letter country code (e.g. USfor the United States, DE for Germany) from the response that IP-API sends us. This response includes a bunch of other information that ip-api can guess from the IP address, but we’re only interested in the country code for now.
  5. Flask uses the @app.route("/") decorator to map specific URLs to specific functions in our code. In this case, the default “/” route is what will automatically trigger when a visitor loads our site.
  6. Our home function finds the visitor’s IP address (this can get more complicated, but it should work in many cases), passes it along to our get_country function checks whether or not the user is from a country where the majority of residents speak French and returns Bonjour or Hello based on this.

Consequently, it is possible to initiate a similar function in other languages designed for web applications and complex web sites.

Related:-20 Pro Tips to make Windows 10 work

Other options and limits in IP-based geolocation

Geolocation is not 100% accurate. Generally, a web app should duly account for a user who has an IP address different from his/her real location. If your web application behaves differently in different countries, it is good to have flexibility in overriding location.

Other ways to track a visitor’s location are:

  • Using DNS host to find out the approximate location. Services like GeoDNS finds the DNS host nearest to the visitor, and we can infer their estimated location.
  • We can find out a visitor’s location by locating the nearest cellphone towers and WiFi routers. Google has a geolocation API that offers these services.
  • Smartphones and some laptops come with a technology called GPS (Global Positioning System), which track the person within a few meters of his/her exact location (permission required in the newer mobile operating systems).

Therefore we have now understood how to use geolocation in web apps.