Add marker.
This commit is contained in:
parent
af29d6321f
commit
98d26a4b61
2
app.py
2
app.py
|
@ -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))
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in New Issue