Giter VIP home page Giter VIP logo

leaflet-tutorials-interesting's Introduction

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

leaflet-tutorials-interesting's People

Contributors

twtrubiks avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.