Sep 24, 2021 • Blog

Isochrone API Tutorial: How to Create an Isochrone Map for Your App

facebook iconx icon

Contents

Isochrones are a useful way to show all the locations that can be reached within a time limit and by a mode of transport, displayed on a map.

You can use isochrones in your website or app to allow users to search for the locations they can reach within their preferred travel time and by their preferred transport mode.

In this tutorial, you’ll learn how to create isochrones and integrate them into your application using the TravelTime Isochrone API.

Prerequisites

To follow along with the tutorial, you’ll need the following:

  • The TravelTime Isochrone API.The Isochrone APIcalculates all areas that are reachable within a specified travel time from a start location by any transport mode and allows you to display this on a map. If you’re new to TravelTime, you can sign up for a free API key here.

How the TravelTime Isochrone API works 

The TravelTime API accepts JSON requests and returns a JSON response. On the front end of your application, users can enter the parameters of their search, including:

  • The departure or arrival location
  • The departure or arrival time
  • The mode of transport
  • The travel time limit

You can try this for yourself in our Isochrone API Playground.

Isochrone Playground

Once the request is made, the Isochrone API receives the request and returns a JSON response. The response includes coordinates for points showing the boundaries of shapes reachable within the travel time.

These results can then be displayed on your application or on a map like the example below:

Isochrone_API

1. Make a request to the Isochrone API

The code sample below shows how to visualise a travel time response.

It shows locations within 1 hour from The White House, Washington DC by public transport.

The JSON response includes coordinates. These points show the boundaries of shapes reachable within the corresponding travel time. 

Now let’s visualise this response on a map.

2. Map the response in your app

The image below shows how this response would be displayed on a Leaflet map.

Isochrone_algorithm

We'll need to do the following three things:

  1. First, we need to define parameters for the search. We’ll need to change the name of the start location (The White House) into coordinates using a geocoder.
  2. Second, we need to change the departure time to the ISO format.
  3. Finally, since the TravelTime API only accepts time in the format of seconds, we need to translate the 1-hour travel time into seconds which is 60 minutes x 60 seconds.

Since this code runs only in the browser, we have removed API key from the sample. Like with the JSON request, the code must have headers. These headers are needed to authenticate the request and usually sit on the server side of your app.

3. Geocode the address coordinates

For the start location, we specified The White House. However, the API only accepts coordinates of a location.To change the address into coordinates, we can use the TravelTime geocoding endpoint.

The function below sends a request for the geocoder:

4. Generate your request

Now that we have everything we need for the request, we can write the code that would generate the request. 

5. Create the map view

Finally, we need to call a function to set up a map with a marker at the departure location.

A separate function is used to draw the multipolygon from the response to reflect the isochrone.

Using isochrones in your application

You can use the TravelTime Isochrone API to allow users on your website or app to search for and view the locations they can reach within a specific travel time.

For example, property website, Zoopla, uses the API to help their users visualise potential propertiesin locations within their desired travel time.

Isochrone_app

Similarly, Foxtons also allows users to search for properties within a maximum travel timefrom their workplace:

property search interface with a map

Next steps

With the TravelTime Isochrone API, you can enable your users to search for locations by travel time for any mode of transport, including public transport, cycling and walking.

Coupled with the TravelTime Matrix API, you can also rank and filter thousands of location search results by travel time.

Additionally, TravelTime supports over 100 countries worldwide. You can see all of our supported countries here.

Check out our documentationto learn more about what you can do with the TravelTime API or sign up for a free API key.

Reliable. Fast. Scalable.
Experience the power of the TravelTime API. Start optimising your location-based search and services today.
Try for free
cta accent icon
facebook iconx icon

Contents

Build travel time isochrones with the TravelTime API.

Get started free
cta accent icon

Read related articles

featured
Engineering
How to Build a Recommendation System that Lists Nearby Retail Stores by Travel Time
featured
Engineering
How to Build a Location-Based Recommendation System for an E-Commerce Website
featured
Blog post
Isochrone API Tutorial: How to Create Isochrones with Leaflet & the TravelTime Isochrone API