Last active
October 29, 2015 16:06
-
-
Save michellechandra/a5c9565214564f68135c to your computer and use it in GitHub Desktop.
CartoDB.js and Leaflet Image Overlay
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> | |
<head> | |
<title>Image Overlay with Leaflet</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" /> | |
<link rel="stylesheet" href="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/themes/css/cartodb.css" /> | |
<style> | |
html, body, #map { | |
height: 100%; | |
padding: 0; | |
margin: 0; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="map"></div> | |
<script src="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/cartodb.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> | |
<script> | |
function main() { | |
var imageUrl = 'http://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg', | |
imageBounds = [[40.712216, -74.22655], [40.773941, -74.12544]]; | |
var map = L.map('map', { | |
center: [40.742216, -74.20655], | |
zoom: 11, | |
zoomControl: true | |
}); | |
L.tileLayer('http://{s}.tile.stamen.com/toner/{z}/{x}/{y}.png', { | |
attribution: 'Stamen' | |
}).addTo(map); | |
L.imageOverlay(imageUrl, imageBounds).addTo(map).setOpacity(0.95); | |
cartodb.createLayer(map, 'https://team.cartodb.com/u/chandra/api/v2/viz/fd5891d6-7db4-11e5-84fe-0e31c9be1b51/viz.json') | |
.addTo(map) | |
.on('done', function(layer) { | |
}).on('error', function() { | |
console.log("some error occurred"); | |
}); | |
} | |
window.onload = main; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment