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.
Search address with openlayers
Asked Answered
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
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. –
Charter
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. –
Overwhelming
You can use something like this :
-
- search features in a layer
- search places on the map
Enjoy :)
links are broken –
Skyrocket
© 2022 - 2024 — McMap. All rights reserved.