-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
130 lines (116 loc) · 3.75 KB
/
index.html
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html>
<html>
<head>
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
blockquote.twitter-tweet {
display: inline-block;
font-family: "Helvetica Neue", Roboto, "Segoe UI", Calibri, sans-serif;
font-size: 12px;
font-weight: bold;
line-height: 16px;
border-color: #eee #ddd #bbb;
border-radius: 5px;
border-style: solid;
border-width: 1px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
margin: 10px 5px;
padding: 0 16px 16px 16px;
max-width: 468px;
}
blockquote.twitter-tweet p {
font-size: 16px;
font-weight: normal;
line-height: 20px;
}
blockquote.twitter-tweet a {
color: inherit;
font-weight: normal;
text-decoration: none;
outline: 0 none;
}
blockquote.twitter-tweet a:hover,
blockquote.twitter-tweet a:focus {
text-decoration: underline;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 2,
center: {lat: 10.1, lng: 125.6},
mapTypeId: 'terrain'
});
// Create a <script> tag and set the USGS URL as the source.
var script = document.createElement('script');
script.src = 'detection/data.js';
script.charset = 'utf-8';
document.getElementsByTagName('head')[0].appendChild(script);
map.data.setStyle(function(feature) {
var magnitude = feature.getProperty('people');
return {
icon: getCircle(magnitude)
};
});
}
function getCircle(magnitude) {
return {
path: google.maps.SymbolPath.CIRCLE,
fillColor: 'red',
fillOpacity: .2,
scale: Math.exp(magnitude / 2.7),
strokeColor: 'white',
strokeWeight: .5
};
}
function attachTweet(marker, secretMessage) {
var infowindow = new google.maps.InfoWindow({
content: secretMessage
});
marker.addListener('click', function() {
infowindow.open(marker.get('map'), marker);
});
}
function eqfeed_callback(results) {
map.data.addGeoJson(results);
var bounds = new google.maps.LatLngBounds();
for (var i = 0; i < results.features.length; i++) {
var tweet = results.features[i].properties.tweet;
tweet = '<blockquote class="twitter-tweet"><p>' + tweet + '</p></blockquote>';
tweet += '<blockquote class="twitter-tweet">'
+ results.features[i].properties.hashtags
+ '<br>'
+ results.features[i].properties.time
+ '</blockquote>';
var coords = results.features[i].geometry.coordinates;
var latLng = new google.maps.LatLng(coords[1],coords[0]);
bounds.extend(latLng);
var marker = new google.maps.Marker({
position: latLng,
map: map
});
attachTweet(marker, tweet);
}
map.fitBounds(bounds);
map.setCenter(bounds.getCenter());
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDIIP9GxF0ALrY6kCa2WI6ndIo6wLPz43s&callback=initMap">
</script>
</body>
</html>