我曾经看到一些jscript/jquery的实现方式,可以通过输入邮政编码从谷歌地图API获取经纬度。然而,在我的情况下,我已经有了一组坐标,并想知道是否可能在使用jquery时动态地从API获取文本格式的城市、州结果?
谢谢!
谢谢!
这是一个被称为逆地理编码的过程,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*/
}
});