rainit2006 / Python-room

my python room
0 stars 0 forks source link

myProject #19

Open rainit2006 opened 6 years ago

rainit2006 commented 6 years ago

rainit2006 commented 6 years ago

Task 1, 解析页面 2,匹配关键词 3,生成kml文件 4,把kml文件显示在map上 5,py文件转换成可执行exe文件。

rainit2006 commented 6 years ago

生成kml文件: 利用simplekml库

安装:
pip install simplekml

代码示例:
import simplekml

  latlogs = []
   kname = 'myKML.kml'
    kml = simplekml.Kml()
    for item in route_x:
        location = item[0]
        result = get_google_results(location, API_KEY)
        latlogs.append([result["longitude"], result["latitude"]])
        pnt = kml.newpoint(name=str(location), coords=[(float(result["longitude"]), float(result["latitude"]), float(0))])
        pnt.extendeddata.newdata(name='info', value = item[1:])
    #kml.newlinestring(name='LineString', coords=latlogs)    
    kml.save(kname)    

参考: https://qiita.com/tomo001/items/b375e5fa578eb8880662

kml文件在线显示(利用下面网页) http://kmlviewer.nsspot.net/

rainit2006 commented 6 years ago

利用Google maps API