OU logo

Calling Geolocation and Geocoding Services From the Browser

This activity is simple web page activity that runs purely within the browser. It uses Javascript to make requests to third party online services, process the response, and add display the result by dynamically adding it to the web page HTML.

You can view the code used by selecting the "View Source" option in your browser: how to "view source" in different browsers.

One of the attractions of APIs (Application Progamming Interfaces) is that you can call them from a wide variety of programming environments.
The web browser is one such environment. Calls are made to online webservices using Javascript, which typically respond using JSON, the Javascript Object Notation. This JSON data is processed by further Javascript code and used to customise the HTML markup that is rendered by your browser.
This web page provides several working examples of how geolocation services can be accessed from the browser.

Activity: Browser location lookup

Click the Browser geolocate... button to get your coordinates from the browser location service.
You will need to grant the browser permission to use location services. Note this is a "black box" lookup - you don't get to see what information the browser passes to the geolocation lookup service.


Activity: Geocoding demo

Enter an address to try the Google Maps API geocoder:

Activity: Postcode Geocoding demo

Get random postcode:
Enter a postcode to try the postcodes.io API geocoder:

Activity: Reverse Geocoding to Postcode demo

Enter latitide and longitude in the form LATITUDE,LONGITUDE to try the postcodes.io API reverse geocoder:

Activity: IP based Geocoding Demo

IP based geolookup