Putting results on a map

Background

One of the most common reasons for forward geocoding (converting from an address or placename to coordinates) is to then display those results as points on a map.

Displaying geocoding results on a map

Mapping software needs precise coordinates like those returned by our geocoder to know exactly where to position pins on a map.

Basically, the process is
  1. You have an address
  2. You geocode the address to turn it into coordinates
  3. You pass those coordinates to a mapping library to display a pin on a map

You can use the OpenCage geocoding API for step 2 of this process.

Which maps can you use to display geocoding results?

Some geocoding services, for example Google, restrict where you can display the results their geocoder returns. They require that you only display results on their maps, or that you purchase an expensive license if you'd like to display the map behind a firewall, or that you can only store the geocoding results for a limited timeperiod or while you remain a customer.

Because we use open data you are free to display results on any mapping software you like. This is one of the many benefits of using open data.

How to display the results on the map

The exact technical process will depend on which mapping software you are using, but most are similar.

Almost all web and mobile based maps are manipulated via the programming language javascript.

It is important to understand the distinction between mapping libraries: javascript code libraries that allow you to add a map to a webpage, and mapping providers: services that create map tiles that you can display on a webpage by using a mapping library. Some companies like Google provide mapping libraries and maps. Others provide only maps which you can integrate with open source mapping libraries.

There are many companies offering maps based on OpenStreetMap. We recommend Thunderforest.

Here is a list of popular web mapping libraries
  • Leaflet is a very popular, beginner-friendly, open source library. In the QuickStart tutorial they show how to add a pin (a "marker", in Leaflet terminology) to a map at any coordinates.
  • OpenLayers is another mature, open source mapping library, typically used for more complex mapping applications.
  • Google Maps API is probably the most widely used, non-open source mapping library, they also provide maps.

This is just a brief overview, there are many other mapping applications, some available for free, others costing money. But all work on the same basic concept. You convert addresses into coordinates and then use the coordinates to position points on a map.

Happy geocoding!

Start your free trial

2,500 geocoding API requests per day.

No credit card required.