Mar*_*ark 7 javascript jquery google-maps google-maps-api-3
我已经看到了这个概念的一些jscript/jquery实现,你可以输入一个邮政编码并从google maps api获得一个long/lat.
但是,在我的情况下,我已经有了一组坐标,并且想知道当我们通过jquery提供长/纬度时,是否可以动态地从API获取文本City,State结果?
谢谢!
kie*_*ran 17
这是一个称为反向地理编码的过程,谷歌有相当广泛的文档.
一个例子是:
$.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*/
}
});
Run Code Online (Sandbox Code Playgroud)