2014-12-06 06:01:24 +08:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Static bubble map | CartoDB.js</title>
|
|
|
|
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
|
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
|
2018-12-03 21:53:13 +08:00
|
|
|
<link rel="shortcut icon" href="https://cartodb.com/assets/favicon.ico" />
|
2014-12-06 06:01:24 +08:00
|
|
|
<style>
|
|
|
|
html, body, #map {
|
|
|
|
height: 100%;
|
|
|
|
padding: 0;
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
</style>
|
2018-12-03 21:53:13 +08:00
|
|
|
<link rel="stylesheet" href="https://libs.cartocdn.com/cartodb.js/v3/themes/css/cartodb.css" />
|
|
|
|
<!--[if lte IE 8]>
|
|
|
|
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/themes/css/cartodb.ie.css" />
|
|
|
|
<![endif]-->
|
2014-12-06 06:01:24 +08:00
|
|
|
<script type="sql/html" id="cartocss_template">
|
|
|
|
Map {
|
|
|
|
-torque-frame-count:0.5;
|
|
|
|
-torque-animation-duration:0;
|
|
|
|
-torque-time-attribute:"cartodb_id";
|
|
|
|
-torque-aggregation-function:"max(no2)";
|
|
|
|
-torque-resolution:2;
|
|
|
|
-torque-data-aggregation:cumulative;
|
|
|
|
}
|
|
|
|
#aqi{
|
|
|
|
comp-op: lighter;
|
|
|
|
marker-fill-opacity: 0.9;
|
|
|
|
marker-line-color: #FFF;
|
|
|
|
marker-line-width: 1.5;
|
|
|
|
marker-line-opacity: 1;
|
|
|
|
marker-type: ellipse;
|
|
|
|
marker-width: 30;
|
|
|
|
marker-fill: #F84F40;
|
|
|
|
[value < 50]{
|
|
|
|
marker-width: 24;
|
|
|
|
[value < 40]{
|
|
|
|
marker-width: 18;
|
|
|
|
[value < 30]{
|
|
|
|
marker-width: 12;
|
|
|
|
[value < 20]{
|
|
|
|
marker-width: 6;
|
|
|
|
[value < 10]{
|
|
|
|
marker-width: 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="map"></div>
|
|
|
|
|
|
|
|
<!-- include cartodb.js library -->
|
2018-12-03 21:53:13 +08:00
|
|
|
<script src="https://libs.cartocdn.com/cartodb.js/v3/cartodb.uncompressed.js"></script>
|
2014-12-06 06:01:24 +08:00
|
|
|
|
|
|
|
<script>
|
|
|
|
function main() {
|
|
|
|
var map = new L.Map('map', {
|
|
|
|
zoomControl: false,
|
|
|
|
center: [39.9304, 116.423239],
|
|
|
|
zoom: 8
|
|
|
|
});
|
2018-12-03 21:53:13 +08:00
|
|
|
var layer = L.tileLayer('https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png',{
|
|
|
|
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a href="http://cartodb.com/attributions">CartoDB</a>'
|
2014-12-06 06:01:24 +08:00
|
|
|
}).addTo(map);
|
|
|
|
|
|
|
|
cartodb.createLayer(map, {
|
|
|
|
type: "torque",
|
|
|
|
order: 1,
|
|
|
|
options: {
|
|
|
|
table_name: "harvard_aqi",
|
|
|
|
user_name: "andrew",
|
|
|
|
tile_style: $('#cartocss_template').html()
|
|
|
|
}
|
2018-12-03 21:53:13 +08:00
|
|
|
}, {
|
|
|
|
https: true,
|
2018-12-03 23:14:42 +08:00
|
|
|
tiler_protocol: 'https',
|
|
|
|
tiler_port: 443
|
2014-12-06 06:01:24 +08:00
|
|
|
}).done(function(layer) {
|
|
|
|
map.addLayer(layer);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// you could use $(window).load(main);
|
|
|
|
window.onload = main;
|
|
|
|
</script>
|
|
|
|
</body>
|
2018-12-03 21:53:13 +08:00
|
|
|
</html>
|