Skip to content

Instantly share code, notes, and snippets.

@ebrelsford
Created March 28, 2017 14:43
Show Gist options
  • Save ebrelsford/6e7cd97faa59d912ead24df9be089767 to your computer and use it in GitHub Desktop.
Save ebrelsford/6e7cd97faa59d912ead24df9be089767 to your computer and use it in GitHub Desktop.
Adding zoom in and zoom out buttons with Carto.js v3
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<!--
Load Carto's code so we can pull in our Carto maps.
-->
<link rel="stylesheet" href="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/themes/css/cartodb.css" />
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
width: 100%;
}
#map {
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
$(document).ready(function () {
cartodb.createVis('map', 'https://thenewschool.carto.com/u/brelsfoeagain/api/v2/viz/6b3c46d3-2025-4214-9081-dd187fa9d3f9/viz.json')
.done(function (vis, layers) {
// Get the "native" Leaflet map and add a zoom control to it
vis.getNativeMap().addControl(L.control.zoom());
});
});
</script>
<script src="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/cartodb.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment