-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
141 lines (120 loc) · 5.16 KB
/
index.html
File metadata and controls
141 lines (120 loc) · 5.16 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
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
131
132
133
134
135
136
137
138
139
140
141
<!DOCTYPE html>
<html>
<head>
<title>Interactive information display of point emissions </title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.5.1/dist/leaflet.css" integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" crossorigin=""/>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<script src="https://unpkg.com/leaflet@1.5.1/dist/leaflet.js" integrity="sha512-GffPMF3RvMeYyc1LWMHtK8EbPv0iNZ8/oTtHPx9/cc2ILxQ+u905qIwdpULaqDkyBKgOaB57QTMg7ztg8Jm2Og==" crossorigin=""></script>
<script src="https://unpkg.com/leaflet-providers@1.3.0/leaflet-providers.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-ajax/2.1.0/leaflet.ajax.min.js" integrity="sha256-rVeyUZMfAHhQJ7hvWaHrKknTDdqGcn1gxBBJA++E4z8=" crossorigin="anonymous"></script>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.23.0/moment.min.js"></script>
<script src="https://unpkg.com/jquery@3.3.1/dist/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chroma-js/2.0.3/chroma.min.js"></script>
<style>
body, html, #map {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#title {
position: absolute;
top: 10px;
left: 0;
right: 0;
margin: auto;
z-index: 1000;
width: 500px;
text-align: center;
color: white;
border-radius: 5px;
padding: 10px;
background-color: rgba(0, 0, 0, 0.8);
font-size: 1rem;
font-family: Arial, Helvetica, sans-serif;
text-shadow: 2px 2px #000000;
font-weight: normal;
}
.leaflet-tooltip-pane .text {
color: black;
font-weight: bold;
background: transparent;
border:0;
box-shadow: none;
font-size:1em;
}
</style>
</head>
<body>
<h1 id="title"> Point Emissions of 2018 over Northeast China </h1>
<div id="map"></div>
<div id="plots"></div>
<script>
var map = L.map('map', {
center: [43.880726,125.35118422],
zoom: 6,
minZoom: 5,
maxZoom: 13
});
var bounds = map.getBounds();
var degreeLimit = 10;
bounds._northEast.lat += degreeLimit;
bounds._northEast.lng += degreeLimit;
bounds._southWest.lat -= degreeLimit;
bounds._southWest.lng -= degreeLimit;
map.setMaxBounds(bounds);
var baseMaps = {
"OSM": L.tileLayer.provider("OpenStreetMap.Mapnik"),
"OSM Grayscale": L.tileLayer.provider("OpenStreetMap.BlackAndWhite"),
"CartoDB Positron": L.tileLayer.provider('CartoDB.Positron').addTo(map),
"CartoDB Dark Matter": L.tileLayer.provider("CartoDB.DarkMatter"),
"ESRI WorldImagery": L.tileLayer.provider("Esri.WorldImagery"),
"Google Hybrid": L.tileLayer('http://{s}.google.com/vt/lyrs=s,h&x={x}&y={y}&z={z}',{
maxZoom: 20,
subdomains:['mt0','mt1','mt2','mt3']
}),
"Wikimedia": L.tileLayer.provider("Wikimedia")
}
var regionCounts = L.layerGroup().addTo(map);
var overlayMaps = {
"Region counts": regionCounts
}
L.control.layers(baseMaps, overlayMaps).addTo(map);
var cmap = chroma.scale([chroma.hsv(0, 1, 1), chroma.hsv(90, 1, 1), chroma.hsv(180, 1, 1), chroma.hsv(270, 1, 1)]).mode("hsv").domain([10, 1]);
$.getJSON("C:\Users\ZXL5510\Desktop\Interactive-display-on-map\point_emissions_data.json", function(data) {
console.log(data)
locationSummary = {}
for (var i in data) {
var c = data[i];
if (c.LocationName == 'Waitemata') c.LocationName = "Auckland";
if (c.LocationName == 'Southern DHB') c.LocationName = "Dunedin";
c.LocationName = c.LocationName.replace(" Region", "")
if (!locationSummary[c.LocationName]) {
locationSummary[c.LocationName] = {
latlong: c.LocationCentrePoint.coordinates.reverse(),
name: c.LocationName,
count: 1
}
} else {
locationSummary[c.LocationName].count++;
}
}
for (var i in locationSummary) {
var l = locationSummary[i]
var radius = l.count;
if (radius < 10) radius = 10;
var marker = L.circleMarker(l.latlong, { radius: radius, color: cmap(l.count) }).bindTooltip(l.name).addTo(map);
var text = L.tooltip({
permanent: true,
direction: 'center',
className: 'text'
}).setContent("" + l.count).setLatLng(l.latlong).addTo(regionCounts);
}
});
</script>
</body>
</html>