Commerce Layer will be proud to sponsor the next JAMstack Conf in London — 09-10 July, 2019 🎉 Stay tuned!



A useful tool to automatically convert a street address into geographic coordinates

Geocoding is the process of transforming:

  • a street address,
  • other description of a location into geographic coordinates, like latitude and longitude.

Vice versa, reverse geocoding is the process of converting geographic coordinates into a human-readable address.

To handle these functionalities, Commerce Layer uses geocoders. They are external services that perform the conversion and validation of the addresses.

The geocoder you create while setting up your Commerce Layer’s Organization is an extra element you can add to your Market.

It is defined by:

  • a name (the internal identifier for this resource within your Organization),
  • a type, the actual service that performs the validation,
  • an API Key (the one provided by the selected geocoding service).

Once set up, a Commerce Layer’s geocoder runs in the background. For any new street address, validation is performed by the geocoding service associated with that specific market. Then the address is converted into a couple of geographic coordinates. There’re several uses of the address coordinates:

  • display the address on an interactive map within the back office,
  • place markers on that map,
  • properly position the map itself.

At this time, Commerce Layer supports two geocoding services: Google and Bing. You can find here all the information on how to get an API Key from the Google API Console, and here the official support for Bing Maps API.


Geocoding is an option, but it’s not strictly necessary. Then why should you use a geocoder? Also, if you do, why should you use a specific geocoding service instead of another? Let’s try to answer these two questions.

Why geocoding?

Geocoding is more than converting addresses into latitudes and longitudes. It’s a crucial step towards ecommerce operational stability and reliability. That’s because, besides the strategic value that location data delivers, reliable coordinates are necessary for maintaining reliable service.

As mentioned above, you can set up a Market even without selecting a geocoder. Using one of the provided geocoding services is recommended, for several reasons.

  • Accuracy
    Generic addresses can be incorrect (mostly because of a human mistake), inaccurate (are you aware of how often road networks changes?) and unprecise (think about a big industrial area which can encompass many entrances). All these flaws can be fixed through geocoding.

  • Universality
    Different countries work with different metric systems. Different software and tools do not necessarily locate one address in the same spot. Across countries, regions, languages (and even applications), latitudes-longitudes are equal. This is the reason why - again - this inconvenience vanish by using latlons instead of addresses.

  • Validation
    It is a well-known fact that address validation is a complicated issue. Being able to geocode a physical street address is a good measure of the “authenticity” of the address itself. If we want to make this sound very easy: to be sure the place where we’re supposed to deliver the goods exists.

Commerce Layer’s policy is to accept every shipping and billing address, whether geocoded or not (so that the checkout process does not get stuck). In parallel, Commerce Layer provides the backend user with the outcome of the address validation. The goal is to help them make a better decision about the order approval.

Which geocoder?

There isn’t a firm and fast rule that can help you choose a specific geocoding service instead of another. There are countries or regions in which one works better than the other (regarding conversion accuracy, performance speed). In this respect, the situation is evolving, and you can fine-tune your choice based on your tests or experience. It’s quite established that - for instance - Google’s geolocation works better with addresses located in Europe and US, while, if you need to geolocate some Korean or Japanese ones, you’d better use Bing.