forked from CartoDB/carto.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleaflet_vector.html
60 lines (47 loc) · 1.81 KB
/
leaflet_vector.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
<!DOCTYPE html>
<html>
<head>
<title>Leaflet vector example | 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"/>
<link rel="shortcut icon" href="http://cartodb.com/assets/favicon.ico" />
<style>
html, body, #map {
height: 100%;
padding: 0;
margin: 0;
}
</style>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.2/leaflet.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.2/leaflet.ie.css" />
<![endif]-->
</head>
<body>
<div id="map"></div>
<!-- include cartodb.js library -->
<script src="http://cdn.leafletjs.com/leaflet-0.6.2/leaflet.js"></script>
<script src="http://libs.cartocdn.com/cartodb.js/v3/cartodb.core.js"></script>
<script>
function main() {
var map = L.map('map', {
zoomControl: false,
center: [43, 0],
zoom: 3
})
var sql = new cartodb.SQL({ user: 'examples', format: 'geojson' });
L.tileLayer('http://tile.stamen.com/toner/{z}/{x}/{y}.png', {
attribution: 'Stamen'
}).addTo(map);
// create the layer and add to the map, then will be filled with data
var countriesLayer = L.geoJson().addTo(map);
//sql.execute("select * from european_countries_e").done(function(geojson) {
//sql.execute("select * from european_countries_e where area::float > {{area}}", { area: 10000 }).done(function(geojson) {
sql.execute("select ST_Simplify(the_geom, 2) as the_geom from european_countries_e").done(function(geojson) {
countriesLayer.addData(geojson);
});
}
window.onload = main;
</script>
</body>
</html>