I have Longitude and Latitude, I would like to connect to Geocoding or Nominatim and get the address of these Lat and Lon.

I want to do it in OpenLayers 3 using OSM.

With help from @ThomasG77, I implemented ReverseGeocoding in my code with this function:

function simpleReverseGeocoding(lon, lat) {
    fetch('http://nominatim.openstreetmap.org/reverse?format=json&lon=' + lon + '&lat=' + lat).then(function(response) {
      return response.json();
     }).then(function(json) {

     return json.display_name;

But the answer of the JSON is:

Promise { <state>: "pending" }

When I show the address in my console:

console.log('http://nominatim.openstreetmap.org/reverse?format=json&lon=' + lon + '&lat=' + lat);

The address that it send is Kenia, or "Unable to Geocode"

Obviously, console.log(json.display_name); is undefined.

Do I have to know something about headers or something similar?


2 Answers 2


Just use the Nominatim reverse geocoding API.

After, it's mainly about knowing HTML and JavaScript.

I've done a simple demo for reverse geocoding using OpenLayers. You can look at the code on this GIST

  • This example is just that I need. However, it seem that not working. Maybe is my browser or something like that. Oct 31, 2017 at 9:14
  • Done some changes to accommodate with IE. It should work now with any recent browsers including IE10+.
    – ThomasG77
    Oct 31, 2017 at 15:58
  • Now it working correctly. Many thanks. Is jast that I need. Nov 1, 2017 at 9:58
  • Thanks for your patient. So, I implemented your code. I have to answer my question because is so long. Nov 3, 2017 at 11:45

I'm not aware of Lat/Long input, only address.

This Useful 3rd party libraries3

You may be able to find something useful here.

Library Description Maintainer

The libraries below provide additional functionality by extending OpenLayers or integrating well with it.

  • OL-Cesium Cesium integration library. OpenLayers
    OL3-LayerSwitcher Layer control for OpenLayers. Matt Walker
    OL3-Popup Basic popup overlay for OpenLayers. Matt Walker
    JSTS JavaScript Topology Suite. Björn Harrtell
    OL3-Geocoder Geocoder Nominatim for OpenLayers. Jonatas Walker
    OL3-Photon Photon geocoder for OpenLayers. Thomas Gratier
    OL3-ContextMenu Custom Context Menu for OpenLayers. Jonatas Walker
    OL3-Google-Maps Google Maps integration library. Mapgears
    OL3-PanZoom PanZoom and PanZoomBar controls for OpenLayers. Mapgears
    OL3-Ext Miscellanous classes and functions for OpenLayers. Jean-Marc Viglino
    OL3-AnimatedCluster A cluster layer for OpenLayers that animates clusters on
    zoom change and a select interaction that spread out cluster to allow feature selection in it. Jean-Marc Viglino
    OL3-Projection-Switcher An OpenLayers Control to switch between projections. NSIDC
    Olé Integration of OpenLayers and Esri ArcGIS REST services. Boundless
    React OpenLayers A minimal React wrapper of OpenLayers 3+ written in
    TypeScript Allen Kim
    GWT-OpenLayers 3 A GWT wrapper for OpenLayers 3+ written in Java Tino Desjardins

This option is for address input, OpenLayers 3 Control Geocoder, ol-geocoder

A geocoder extension for OpenLayers 3. Requires OpenLayers v3.11.0 or higher.

enter image description here

  • Ok Thank you. I am using this Library precisely, however, I don´t find the way for look a address by Lat and long. Oct 31, 2017 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.