Skip to content

Instantly share code, notes, and snippets.

@RuanAragao
Created July 27, 2016 17:06
Show Gist options
  • Save RuanAragao/3a07edebd5beef7fd193d07f803c5695 to your computer and use it in GitHub Desktop.
Save RuanAragao/3a07edebd5beef7fd193d07f803c5695 to your computer and use it in GitHub Desktop.
Flask Google Maps example
{{
googlemap(
identifier="no-controls-map",
lat=37.4419,
lng=-122.1419,
zoom_control=False,
maptype_control=False,
scale_control=False,
streetview_control=False,
rotate_control=False,
fullscreen_control=False
)
}}
on the head:
{{"decoupled-map"|googlemap_js(37.4419, -122.1419, markers=[(37.4419, -122.1419)])}}
on the body:
{{"decoupled-map"|googlemap_html(37.4419, -122.1419)}}
{% with map=googlemap_obj("another-map", 37.4419, -122.1419, markers=[(37.4419, -122.1419), (37.4300, -122.1400, "Hello")]) %}
{{map.html}}
{{map.js}}
{% endwith %}
View:
from flask_googlemaps import Map
@app.route("/")
def mapview():
mymap = Map(
identifier="cluster-map",
lat=37.4419,
lng=-122.1419,
markers=[{'lat': 37.4419, 'lng': -122.1419}, {'lat': 37.4500, 'lng': -122.1419}, {'lat': 36.4419, 'lng': -120.1419}]
cluster=True,
cluster_gridsize=10
)
return render_template('clustermap.html', clustermap=clustermap)
Template:
in head:
{{clustermap.js}}
in body:
{{clustermap.html}}
{{googlemap("simple-map", 37.4419, -122.1419)}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment