-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtemplate.jinja2
67 lines (61 loc) · 1.96 KB
/
template.jinja2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Info windows</title>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
function bindInfoWindow(marker, map, infowindow, html) {
marker.addListener('mousedown', function() {
infowindow.setContent(html);
infowindow.open(map, this);
});
}
function initMap() {
var uluru = {lng: {{ map_center[1] }}, lat: {{ map_center[0] }} };
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 14,
center: uluru
});
var appartments = {{ appartments }};
window.appartments = appartments;
for (apt_idx in appartments) {
appartment = appartments[apt_idx];
if (appartment.lat_long == null) {
continue;
}
var contentString = '<div id="content">' +
'<h4>' + appartment.title + '</h4>' +
'<h5>$' + appartment.price + '</h5>' +
'<p><strong>' + appartment.date + '</strong> ' + appartment.description + '</p>' +
'<a href="' + appartment.link + '">Link</a>' +
'</div>';
infowindow = new google.maps.InfoWindow();
marker = new google.maps.Marker({
position: {lat: appartment.lat_long[0], lng: appartment.lat_long[1]},
map: map,
title: appartment.title,
optimized: false
});
bindInfoWindow(marker, map, infowindow, contentString);
}
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key={{ js_api_key }}&signed_in=true&callback=initMap">
</script>
</body>
</html>