3

I am trying to move away from all Google products.

For mapping, I am using AngularJS 1.x and Leaflet.

I was surprised to find that Leaflet does not support geocoding, where I pass an address and get a latitude/longitude. I need that in order to add markers to the map.

I am looking for a Geocoder which:

  • is free for commercial use
  • is stable and likely to stay so for many years
  • has a really simple API, preferably just HTTP GET, which will take a city name or street name and return latitude/longitude (not that I don't really need great accuracy; city level resolution will be enough in some cases)
  • a batch interface is "nice to have", but I will probably just fire off individual requests
  • coverage of the UK will currently suffice, but all of Europe would be "nice to have"

What can you recommend?

4

OpenStreetMap, which is free for commercial use, has a geocoding tool called Nominatim. Its API is based on HTTP GET and you have a choice of different formats to return (e.g. JSON, XML).

As an example, consider Stack Overflow's New York address. Open the following URL in your browser: https://nominatim.openstreetmap.org/search?q=110+william+street,+new+york&format=json

and you'll get the following results:

[
  {
    "place_id": 140185133,
    "licence": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
    "osm_type": "way",
    "osm_id": 278078924,
    "boundingbox": [
      "40.7084229",
      "40.7091243",
      "-74.0071802",
      "-74.0062953"
    ],
    "lat": "40.7087755",
    "lon": "-74.0067691170635",
    "display_name": "110 William Street, 110, William Street, Financial District, Manhattan, Manhattan Community Board 1, New York County, New York City, New York, 10038, USA",
    "class": "building",
    "type": "yes",
    "importance": 0.511
  }
]
| improve this answer | |
  • I don't understand how I overlooked that :-) Thanks a a 1,000,000 – Mawg says reinstate Monica Apr 5 '19 at 8:58
  • Do you know if it handles batch requests? Can I pass it a list of addresses? I tried multiple q= parameters, but it only processes the last one. Maybe there is another way? – Mawg says reinstate Monica Apr 5 '19 at 10:03
  • 1
    I don't know of any ... – Glorfindel Apr 5 '19 at 10:28
  • Nvm, I used the answer to this question to let me bind a parameter (company name) to each geocode request and that helps me case; when each of the asynch responses arrives,as well as address data, I have the company name to associate with it. Thanks again for your help :-) – Mawg says reinstate Monica Apr 5 '19 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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