20150330 - victor gau - maps
-
Upload
victor-gau -
Category
Software
-
view
91 -
download
3
Transcript of 20150330 - victor gau - maps
Creating Map Applications using Python
Victor Gau20150330
Outline
● Static Map Applications● Interactive Map Applications● Real Time Google Earth Applications
Python development web server
python -m CGIHTTPServer
Static Map Applications
Google Static Maps API
● Google Static Maps API 可讓您在自己的網頁中嵌 入 Google 地圖,完全不需使用 JavaScript 或任
何動態網頁載入。● Google 靜態地圖服務會根據透過標準 HTTP 要求傳送的網址參數建立您的地圖,並將該地圖以圖片
的形式傳回,讓您可以顯示在網頁上。
● https://developers.google.com/maps/documentation/staticmaps/
Google Static Maps API
● http://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318&markers=color:red%7Ccolor:red%7Clabel:C%7C40.718217,-73.998284&sensor=false
Google Static Maps API
DEMO
Interactive Map Applications
Folium
● Mapping using Leaflet.js library.● Built-in tilesets from OpenStreetMap,
Mapbox, and Stamen● Supports custom tilesets with Mapbox or
Cloudmade API keys.● To install => “pip install folium”● https://folium.readthedocs.org/en/latest/
Base Maps
import folium
map = folium.Map(location=[45.5236, -122.6750])
map.create_map(path='osm.html')
Markers
● Simple Markers● Circle Markers● Polygon Markers
http://folium.readthedocs.org/en/latest/#markers
Tilesets
● ‘OpenStreetMap’● ‘Mapbox Bright’ (Limited levels of zoom)● ‘Mapbox Control Room’ (Limited levels of zoom)● ‘Stamen Terrain’● ‘Stamen Toner’
http://folium.readthedocs.org/en/latest/#tilesets
DEMO
DEMO
Real Time Google Earth Applications
KML
https://developers.google.com/kml/documentation/
https://developers.google.com/kml/documentation/kmlreference
<LookAt> in KML
https://developers.google.com/kml/documentation/cameras
NetworkLink Concept
● A network link contains a <Link> element with an <href> (a hypertext reference) that loads a file.
● The <href> can be a local file specification or an absolute URL. Despite the name, a <NetworkLink> does not necessarily load files from the network.
KML Interactive Sampler
DEMO
Google Earth API (Deprecated)
NASA WorldWind
Thank You!
Flask
● python micro web framework● pip install flask● http://flask.pocoo.org/● http://flask.pocoo.org/docs/0.10/quickstart/#quickstart
Flask Hello World
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run()
Rendering Template
from flask import render_template
@app.route('/hello/')
@app.route('/hello/<name>')
def hello(name=None):
return render_template('hello.html', name=name)
<!doctype html>
<title>Hello from Flask</title>
{% if name %}
<h1>Hello {{ name }}!</h1>
{% else %}
<h1>Hello World!</h1>
{% endif %}
jinja2
● template engine● http://jinja.pocoo.org/docs/dev/● {% block content %}, {% endblock %}● {% extends “index.html” %}● {{ variable }}● {{ variable | filters }}● {# comments #}