8

I have a project in PHP and I'm using openlayers for maps, but I need to locate bookmarks by passing a list of addresses, it has to be a free geocoder since there are many addresses. Thank you very much.

2 Answers2

7

For geocoding your place adress for free, use nominatim.openstreetmap.org geocoder with jquery ajax this way :

var data = {
    "format": "json",
    "addressdetails": 1,
    "q": "22 rue mouneyra bordeaux",
    "limit": 1
};
$.ajax({
  method: "GET",
  url: "https://nominatim.openstreetmap.org",
  data: data
})
.done(function( msg ) {
    console.log( msg );
});

You will receive a yummy json object :

address: {
    city: "Bordeaux"
    country: "France"
    country_code: "fr"
    county: "Bordeaux"
    house_number: "22"
    postcode: "33000"
    road: "Rue Mouneyra"
    state: "Nouvelle-Aquitaine"
    suburb: "Saint-Augustin - Tauzin - Alphonse Dupeux"
}
boundingbox:["44.8341251", "44.8342251", "-0.581869", "-0.581769"]
class: "place"
display_name: "22, Rue Mouneyra, Saint-Augustin - Tauzin - Alphonse Dupeux, Bordeaux, Gironde, Nouvelle-Aquitaine, France métropolitaine, 33000, France"
importance: 0.411
lat: "44.8341751"
licence: "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright"
lon: "-0.581819"
osm_id: "2542169758"
osm_type: "node"
place_id: "26453710"
type: "house"

You can then geocode multiple places in a loop.

Cheers

rafa226
  • 536
  • 8
  • 17
  • 1
    I was reading about nominatim and it looks like it's limited to 1 query per second, so that probably wouldn't help with geocoding a whole list of addresses. – ekolis May 24 '19 at 18:09
  • 2
    Yes and if you do too much requests, you will get banned, so in the loop you have to insert a timeout, or a delay. – rafa226 May 25 '19 at 19:14
0

You can use something like this :

  1. Search bar

    • search features in a layer
    • search places on the map
  2. Search features

Enjoy :)

Nazim Kerimbekov
  • 4,712
  • 8
  • 34
  • 58
Svinjica
  • 2,389
  • 2
  • 37
  • 66