forked from CartoDB/labs-cesiumjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple.html
80 lines (73 loc) · 3.49 KB
/
simple.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<title>CartoDB - Cesium example (simple)</title>
<link href="//cartodb-libs.global.ssl.fastly.net/cartodbui/assets/3.4.9/favicons/favicon.ico?1411985985" rel="shortcut icon" type="image/vnd.microsoft.icon" />
<link href='//fonts.googleapis.com/css?family=Lato:300,400,700' rel='stylesheet' type='text/css'>
<link href="css/guide.css" media="screen" rel="stylesheet" type="text/css" />
<link href="Cesium/Widgets/widgets.css" media="screen" rel="stylesheet" type="text/css" />
<link href="css/app.css" media="screen" rel="stylesheet" type="text/css" />
<script src="Cesium/Cesium.js"></script>
<style>
html, body, #cesiumContainer {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
</style>
</head>
<body>
<div id="cesiumContainer"></div>
<script src="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/cartodb.core.js"></script>
<script src="cesium-cartodb.min.js"></script>
<script>
// Basemap
var basemapProvider = new Cesium.CartoDBImageryProvider({
url: 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png'
});
var viewer = new Cesium.Viewer('cesiumContainer', {
imageryProvider: basemapProvider,
baseLayerPicker: false,
timeline: false,
animation: false,
geocoder: false
});
// Tile data layer (circles)
var layerData = {
user_name: 'cartotraining',
maps_api_template: 'https://{user}.cartodb.com', // Optional
sublayers: [{
sql: "SELECT * FROM ne_10m_populated_places_simple WHERE adm0_a3 like 'USA' AND pop_max > 1000000",
cartocss: '#layer {marker-line-color: #FFF; marker-line-width: 1; marker-width: 10; marker-fill: #3E7BB6;}'}]
};
cartodb.Tiles.getTiles(layerData, function (tiles, err) {
if (tiles == null) {
console.log("error: ", err.errors.join('\n'));
return;
}
viewer.scene.imageryLayers.addImageryProvider(new Cesium.CartoDBImageryProvider({
url: tiles.tiles[0]
}));
});
// SQL API layer (rendered by Cesium - bubbles)
var dataSource = new Cesium.GeoJsonDataSource();
viewer.dataSources.add(dataSource);
var sql = new cartodb.SQL({user: 'cartotraining', format: 'geoJSON'});
sql.execute("SELECT * FROM ne_10m_populated_places_simple WHERE adm0_a3 like 'USA' AND pop_max > 1000000")
.done(function (data) {
dataSource.load(data)
.then(function () {
})
})
.error(function (errors) {
// errors contains a list of errors
console.log("errors:" + errors);
});
</script>
</body>
</html>