Displaying geocoding results on a map
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.
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
- You have an address
- You geocode the address to turn it into coordinates
- 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.
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.