-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
116 lines (90 loc) · 4.07 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
<!-- <link type="text/css" href="/static/css/main.css" rel="stylesheet">
Beautify Markers come from here https://github.com/marslan390/BeautifyMarker
-->
<html>
<head>
<title>Looking At Summit Attendees</title>
<script src="http://code.jquery.com/jquery-2.0.0.min.js"></script>
<link href='http://fonts.googleapis.com/css?family=Milonga' rel='stylesheet' type='text/css'>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <style type="text/css">
body {
padding: 0;
margin: 0;
}
html, body, #map {
height: 100%;
font-family: 'Milonga', cursive;
}
.leaflet-container .leaflet-control-zoom {
margin-left: 13px;
margin-top: 70px;
}
#map { z-index: 1;}
#title { z-index: 2; position: absolute; left: 10px; }
</style>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script type="text/javascript" src="/static/js/leaflet-providers.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/leaflet-beautify-marker-icon.css">
<script src="/static/js/leaflet-beautify-marker-icon.js"></script>
<script src="/static/js/leaflet-beautify-marker.js"></script>
</head>
<body>
<div id="map" class="map"></div>
</body>
<script>
var map = L.map('map').setView([37.038, -95.00], 5);
var zippinLayerGroup = L.layerGroup().addTo(map);
var airportpinLayerGroup = L.layerGroup().addTo(map);
// here is a preview for each style https://leaflet-extras.github.io/leaflet-providers/preview/
var stamenLayer = L.tileLayer.provider('Stamen.Terrain').addTo(map);
function getPins(e){
bounds = map.getBounds();
zipurl = "ws/zips";
airporturl = "ws/airports";
$.get(zipurl, pinTheMapWithZip, "json")
$.get(airporturl, pinTheMapWithAirports, "json")
}
function pinTheMapWithAirports(dataObject) {
//Set up the icon
options = {
icon: 'plane',
borderColor: '#8D208B',
textColor: '#8D208B',
backgroundColor: 'transparent'
};
data = dataObject.results
//clear the current pins
map.removeLayer(airportpinLayerGroup);
//add the new pins
var markerArray = new Array(data.length)
for (var i = 0; i < data.length; i++) {
airportData = data[i];
markerArray[i] = L.marker([airportData.coords[1], airportData.coords[0]], {icon: L.BeautifyIcon.icon(options)}).bindPopup(airportData.name + "<br> Passengers: " + airportData.passengers);
}
airportpinLayerGroup = L.layerGroup(markerArray).addTo(map);
}
function pinTheMapWithZip(dataObject) {
options = {
iconShape: 'circle-dot',
borderWidth: 5,
borderColor: 'red'
};
data = dataObject.results
//clear the current pins
map.removeLayer(zippinLayerGroup);
//add the new pins
var markerArray = new Array(data.length)
for (var i = 0; i < data.length; i++) {
zipData = data[i];
markerArray[i] = L.marker([zipData.coords[1], zipData.coords[0]], { icon: L.BeautifyIcon.icon(options)}).bindPopup(zipData.zipcode + "<br> Number Attendees: " + zipData.count);
}
zippinLayerGroup = L.layerGroup(markerArray).addTo(map);
}
map.on('dragend', getPins);
map.on('zoomend', getPins);
map.whenReady(getPins)
</script>
</html>