谷歌地图从邮政编码获取谷歌纵横和经度 [英] google maps Get Latitude and Longitude from zip code
本文介绍了谷歌地图从邮政编码获取谷歌纵横和经度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用google api获得经度和纬度,只需传递邮政编码?
Is it possible to get longitude and latitude using google api just passing zip/postal code ?
感谢任何提示,再见
推荐答案
只需创建 google.maps.Geocoder
,并调用它的 geocode
方法,一个拥有必要属性的对象,它是 GeocoderRequest
。
Simply create an instance of google.maps.Geocoder
and call its geocode
method, passing in an object that possesses the attributes necessary for it to be a GeocoderRequest
.
因此:
$ b $
Thus:
var geocoder = new google.maps.Geocoder();
geocoder.geocode({address: /* zip you got from user input */},
function(results_array, status) {
// Check status and do whatever you want with what you get back
// in the results_array variable if it is OK.
// var lat = results_array[0].geometry.location.lat()
// var lng = results_array[0].geometry.location.lng()
});
这篇关于谷歌地图从邮政编码获取谷歌纵横和经度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文