Python —— Google 地图



Python 提供了可直接将 Google 地图中的地址转换为地理坐标的模块。这有助于查找企业地址和定位不同地址的接近程度。

我们使用一个名为 pygeocoder 的模块来接收地址和地理编码。此模块通过以下命令通过 pip 进行安装。

安装 pygeocoder

pip install pygeocoder 

查找企业地址

我们提交一个企业名称作为输入,程序会给出完整的地址作为输出。该模块使用 Google 地图中的数据在后台检索结果。

from pygeocoder import Geocoder

business_name = "Workafella Business Centre - Hitec city"
print "Searching %s" %business_name
results = Geocoder.geocode(business_name)
for result in results:
    print result

当我们运行上述程序时,会得到以下输出 −

Searching Workafella Business Centre - Hitec city
Western pearl building 1st floor, Hitech City Rd, 
Opposite HDFC Bank, Kondapur, Hyderabad, Telangana 500084, India
广告