Skip to content

Instantly share code, notes, and snippets.

@jsanz
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jsanz/92c80ebd155f8b2e02f5 to your computer and use it in GitHub Desktop.
Save jsanz/92c80ebd155f8b2e02f5 to your computer and use it in GitHub Desktop.
Minimal CartoDB visualization with the CartoDB.js library
<!DOCTYPE html>
<html>
<head>
<title>Trying to hide the layers| 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://libs.cartocdn.com/cartodb.js/v3/themes/css/cartodb.css" />
</head>
<body>
<div id="map"></div>
<!-- include cartodb.js library -->
<script src="http://libs.cartocdn.com/cartodb.js/v3/cartodb.js"></script>
<script>
function main() {
cartodb.createVis('map', 'http://xurxosanz.cartodb.com/api/v2/viz/e0cc9a92-1b24-11e4-b59c-0e10bcd91c2b/viz.json', {
shareable: false,
title: false,
description: false,
search: true,
tiles_loader: true,
center_lat: 0,
center_lon: 0,
zoom: 2,
layer_selector:true,
cartodb_logo: true,
legends: false
})
.done(function(vis, layers) {
layers[1].on('featureOver', function(e, pos, latlng, data) {
cartodb.log.log(e, pos, latlng, data);
});
// you can get the native map to work with it
// depending if you use google maps or leaflet
map = vis.getNativeMap();
// now, perform any operations you need
// map.setZoom(3)
// map.setCenter(new google.maps.Latlng(...))
})
.error(function(err) {
console.log(err);
});
}
window.onload = main;
</script>
</body>
</html>
@bolollo
Copy link

bolollo commented Aug 4, 2014

Hola Xurxo en el fork he puesto el codigo para ocultar las capas al iniciar el mapa. No se si sea la mejor forma de hacerlo pero funciona

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment