Following this GIS SE answer, on this example I remove all interaction on the map so the zoom, panning and any other events are not fired.
Last active
September 14, 2016 09:15
-
-
Save jsanz/5d9adf149673d5854e9d to your computer and use it in GitHub Desktop.
JavaScript CartoDB.js: Leaflet map without any interaction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Disabling all interaction</title> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> | |
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.15/themes/css/cartodb.css" /> | |
<style> | |
html, body, #map{ | |
width: 100%; | |
height: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="map"></div> | |
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.15/cartodb.js"></script> | |
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.15/cartodb.mod.torque.js"></script> | |
<script type="text/javascript"> | |
;(function() { | |
function main() { | |
var vizjson = 'https://jsanz.cartodb.com/api/v2/viz/5044e12c-e473-11e5-ae2b-0e98b61680bf/viz.json'; | |
cartodb.createVis('map',vizjson,{zoomControl:false,scrollwheel:false}) | |
.done(function(viz,layers){ | |
var map = viz.getNativeMap(); | |
// Remove all interaction | |
map.dragging.disable(); | |
map.touchZoom.disable(); | |
map.doubleClickZoom.disable(); | |
map.scrollWheelZoom.disable(); | |
map.boxZoom.disable(); | |
map.keyboard.disable(); | |
if (map.tap) map.tap.disable(); | |
document.getElementById('map').style.cursor='default'; | |
}); | |
} | |
window.onload = main; | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment