-
Notifications
You must be signed in to change notification settings - Fork 0
/
Javascript.js
54 lines (48 loc) · 1.46 KB
/
Javascript.js
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
//function main(){
var piparray = [];
var dataarray = [];
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 3,
center: {lat: 19.148917, lng: 4.265526}
});
getData();
map.data.setStyle(function(feature) {
var magnitude = feature.getProperty('mag');
var timeAgo = feature.getProperty('time');
return {
icon: getCircle(magnitude, timeAgo)
};
});
map.data.addListener('mouseover', function(event) {
$('.infocard').remove();
var source = $("#infocard-template").html();
var template = Handlebars.compile(source);
var context = {title: event.feature.getProperty("place").match(/([A-Z][a-z]+,*\s*)+/g),
supportingtext: " Magnitude" + " " + event.feature.getProperty("mag") + " earthquake, " + event.feature.getProperty("place"),
eqlink: event.feature.getProperty("url")};
$(document.body).append(template(context));
});
}
function getCircle(magnitude, timeAgo) {
return {
path: google.maps.SymbolPath.CIRCLE,
fillColor: 'red',
fillOpacity: (5E11 / timeAgo),
scale: Math.pow(2, magnitude)/2,
strokeColor: 'white',
strokeWeight: .5
};
}
function getData () {
$.get("https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_week.geojson",
function(data){
$.each(data.features, function (index, value){
dataarray.push(value);
})
map.data.addGeoJson(data);
//console.log(dataarray)
});
};
//};