Skip to content

Instantly share code, notes, and snippets.

@michellechandra
Last active October 16, 2015 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michellechandra/5aea65d958c77a295d6c to your computer and use it in GitHub Desktop.
Save michellechandra/5aea65d958c77a295d6c to your computer and use it in GitHub Desktop.
CartoDB CreateVis Zoom Options
<!DOCTYPE html>
<html>
<head>
<title>CreateVis Zoom 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://libs.cartodb.com/cartodb.js/v3/3.15/themes/css/cartodb.css" />
</head>
<body>
<div id="map"></div>
<!-- include cartodb.js library -->
<script src="http://libs.cartodb.com/cartodb.js/v3/3.15/cartodb.js"></script>
<script>
function main() {
cartodb.createVis('map', 'http://documentation.cartodb.com/api/v2/viz/2b13c956-e7c1-11e2-806b-5404a6a683d5/viz.json')
.done(function(vis, layers) {
// change native map functions to set the zoom
var map = vis.getNativeMap();
console.log(map);
map.options.maxZoom = 10;
map.options.minZoom = 3;
// map.panTo([50.5, 30.5]);
// map.doubleClickZoom.disable();
})
.error(function(err) {
console.log(err);
});
}
window.onload = main;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment