index.html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<style>
html, body, #map {
height: 100%;
padding: 0;
margin: 0;
}
</style>
<link rel="stylesheet" href="//libs.cartocdn.com/cartodb.js/v2/themes/css/cartodb.css" />
</head>
<body>
<div id="map"></div>
</body>
<script src="//libs.cartocdn.com/cartodb.js/v2/cartodb.js"></script>
<script>
function main() {
var map = L.map('map', {
zoomControl: false,
center: [43, 0],
zoom: 3
})
L.tileLayer('//tile.stamen.com/toner/{z}/{x}/{y}.png', {
attribution: 'MapBox'
}).addTo(map);
cartodb.createLayer(map, '//examples.cartodb.com/api/v1/viz/european_countries_e/viz.json', {
query: 'select * from {{table_name}} where area::float > 10000'
})
.on('done', function(layer) {
map.addLayer(layer);
layer.on('featureOver', function(e, pos, latlng, data) {
console.log('featureOver')
});
layer.on('featureOut', function(e, pos, latlng, data) {
console.log('featureOut')
});
layer.on('error', function(err) {
cartodb.log.log('error: ' + err);
});
}).on('error', function() {
cartodb.log.log("some error occurred");
});
}
window.onload = main;
</script>
</html>