-
Notifications
You must be signed in to change notification settings - Fork 1
/
challenge-earthquakes2.html
66 lines (58 loc) · 1.82 KB
/
challenge-earthquakes2.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="Getting started with LeafletJS - Challenge Earthquakes" />
<link href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" rel="stylesheet" type="text/css" />
<title>MapTime-Alpes - Leaftlet</title>
<style>
body {
padding: 0;
margin: 0;
}
html, body, #leaflet-map {
height: 100%;
}
</style>
</head>
<body>
<div id="leaflet-map"></div>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<script src='https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-heat/v0.1.3/leaflet-heat.js'></script>
<script>
// MAP
var map = L.map('leaflet-map', {
center: [25.0, -20.0],
zoom: 3,
});
// copyright
var mbAttr = 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, '+
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, '+
'Imagery © <a href="http://mapbox.com">Mapbox</a>',
mbUrl = 'https://{s}.tiles.mapbox.com/v3/{id}/{z}/{x}/{y}.png';
// mapbox gray
var grayscale = L.tileLayer(mbUrl, {
id: 'examples.map-20v6611k',
attribution: mbAttr
});
grayscale.addTo(map);
// add empty heatmap
var heat = L.heatLayer([], { maxZoom: 12 }).addTo(map);
$.ajax({
url: "http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson",
cache: true,
success: function (data) {
// make geojson layer from data
geojsonlayer = L.geoJson(data);
// fit data to map
map.fitBounds(geojsonlayer.getBounds());
// iterate geojson layer, adding to heatmap
geojsonlayer.eachLayer(function(l) {
heat.addLatLng(l.getLatLng());
});
}
});
</script>
</body>
</html>