我有一个PHP项目,我使用openlayers进行地图,但是我需要通过传递地址列表来定位书签,因为有很多地址,所以它必须是免费的地理编码器。非常感谢你。
答案 0 :(得分:1)
要免费对位置地址进行地理编码,请通过以下方式将nominatim.openstreetmap.org地理编码器与jquery ajax结合使用:
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 );
});
您将收到一个美味的json对象:
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"
然后您可以在一个循环中对多个位置进行地理编码。
欢呼
答案 1 :(得分:0)