我已经看到了这个概念的一些 jscript/jquery 反向实现,您可以在其中输入邮政编码并从 google maps api 获取 long/lat。
但是,就我而言,我已经有了一组坐标,想知道当我们通过 jquery 向它提供经度/纬度时,是否可以从 API 动态获取文本城市、州结果?
谢谢!
最佳答案
这是一个名为 reverse geocoding 的进程,Google 对此有相当丰富的文档。
一个例子是:
$.ajax({ url:'http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true',
success: function(data){
alert(data.results[0].formatted_address);
/*or you could iterate the components for only the city and state*/
}
});
关于javascript - 通过 jquery/ajax 使用谷歌地图地理编码从纬度/经度获取城市/州?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13428284/