Content-Length: 303145 | pFad | http://github.com/twtrubiks/leaflet-tutorials-interesting

E7 GitHub - twtrubiks/leaflet-tutorials-interesting: leaflet tutorials interesting use Python Flask
Skip to content

twtrubiks/leaflet-tutorials-interesting

Repository files navigation

leaflet-tutorials-interesting

leaflet tutorials interesting use Python Flask 📝

Leaflet 與 Google Map 比較

安裝套件

確定電腦有安裝 Python 之後

clone 我的簡單範例

git clone https://github.com/twtrubiks/leaflet-tutorials-interesting

接著請在 cmd (命令提示字元) 輸入以下指令

pip install -r requirements.txt

使用方法 以及 執行畫面

先產生模擬資料

python generator_data.py

執行完畢後, app.db 裡會多出 200 筆資料,可以使用 SQLiteBrowser 觀看

alt tag

接著我們設計簡單的 api , 其實就是去讀 app.db 的資料,接著在吐給前端而已。

@app.route("/api", methods=['POST'])
def api():
    db_data = MapPets.query.all()
    infornation_dic = {}
    infornation_list = []
    for data in db_data:
        infornation_dic['data'] = []
        infornation_dic['Name'] = data.Name
        infornation_dic['Picture'] = data.Picture
        infornation_dic['Color'] = data.Color
        infornation_dic['Longitude'] = data.Longitude
        infornation_dic['Latitude'] = data.Latitude
        infornation_list.append(infornation_dic)
        infornation_dic = {}

    return json.dumps(infornation_list)

執行畫面

python app.py

首頁

左上角可以全螢幕

alt tag

alt tag

點隨任一個動物,會跳出名稱和經緯度

alt tag

也有搜索功能

alt tag

選定後,會移到該動物的位置

alt tag

執行環境

  • Python 3.4.3

Reference

License

MIT license

Releases

No releases published

Packages

No packages published








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/twtrubiks/leaflet-tutorials-interesting

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy