-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
67 lines (59 loc) · 1.67 KB
/
script.js
File metadata and controls
67 lines (59 loc) · 1.67 KB
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
var isMapLoaded = false
var isDataLoaded = false
// // Your Javascript code here
// SAMPLE: Grab earthquake data from USGS feed
var EARTHQUAKE_API = 'http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/significant_month.geojson'
$.get(EARTHQUAKE_API)
.done(function(res) {
console.log(res);
earthquakes = res;
// simpleEarthquakeDisplay(res.features);
isDataLoaded = true
displayEarthquakes();
})
.fail(function(error) {
// Do something with the error
})
function initMap() {
isMapLoaded = true
map = new google.maps.Map(document.getElementById('map'), {
zoom: 2,
center: new google.maps.LatLng(2.8,-187.3),
mapTypeId: 'terrain'
});
displayEarthquakes();
}
function displayEarthquakes(){
if (!isMapLoaded || !isDataLoaded){
return
}
eqfeed_callback(earthquakes);
map.data.setStyle(function(feature) {
var magnitude = feature.getProperty('mag');
return {
icon: getCircle(magnitude)
};
});
}
function eqfeed_callback(results) {
map.data.addGeoJson(results);
}
function getCircle(magnitude) {
return {
path: google.maps.SymbolPath.CIRCLE,
fillColor: 'red',
fillOpacity: .2,
scale: Math.pow(2, magnitude) / 2,
strokeColor: 'white',
strokeWeight: .5
};
}
// SAMPLE: Display the earthquake titles on the page
// function simpleEarthquakeDisplay(quakes) {
// var container = $('#sample').empty();
// quakes.forEach(function(quake) {
// var quakeEl = $('<li></li>')
// .text(quake.properties.title)
// .appendTo(container);
// });
// }