Add marker.

This commit is contained in:
Kevin Dungs 2014-11-17 16:59:10 +01:00
parent af29d6321f
commit 98d26a4b61
2 changed files with 13 additions and 6 deletions

2
app.py
View File

@ -19,7 +19,7 @@ def index():
def showMap(threewords): def showMap(threewords):
try: try:
lat, lng = these.decode(threewords) lat, lng = these.decode(threewords)
return template('map', lat=lat, lng=lng) return template('map', lat=lat, lng=lng, threewords=threewords)
except: except:
return template('index', return template('index',
err="Could not find location {}".format(threewords)) err="Could not find location {}".format(threewords))

View File

@ -15,12 +15,19 @@
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js"></script> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js"></script>
<script type="text/javascript"> <script type="text/javascript">
function initialize() { function initialize() {
var mapOptions = { var loc = {
center: { lat: {{ lat }}, lng: {{ lng }}}, lat: {{ lat }},
zoom: 14 lng: {{ lng }}
}; };
var map = new google.maps.Map(document.getElementById('map-canvas'), var map = new google.maps.Map(document.getElementById('map-canvas'), {
mapOptions); center: loc,
zoom: 14
});
var marker = new google.maps.Marker({
position: loc,
map: map,
title: "{{ threewords }}"
});
} }
google.maps.event.addDomListener(window, 'load', initialize); google.maps.event.addDomListener(window, 'load', initialize);
</script> </script>