Created
January 9, 2015 23:06
-
-
Save andy-esch/3c4fd593307dcf3f7a81 to your computer and use it in GitHub Desktop.
Named map with createLayer
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>Named maps with createLayer | CartoDB</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" /> | |
<!-- Map takes up full browser window --> | |
<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> | |
<!-- Drop your code between the script tags below! --> | |
<script> | |
//Workaround for named maps | |
cartodb.uniqueCallbackName = function() { return 'cdb_' + new Date().getTime() } | |
// create leaflet map | |
var map = L.map('map', { | |
zoomControl: false, | |
center: [39.7643389, -104.8551114], | |
zoom: 3 | |
}) | |
// add a base layer | |
L.tileLayer('http://tile.stamen.com/toner/{z}/{x}/{y}.png', { | |
attribution: 'Stamen' | |
}).addTo(map); | |
cartodb.createLayer(map, { | |
user_name: 'andye', | |
type: 'namedmap', | |
named_map: { | |
name: "namedmap_ex_1_9_2015" | |
} | |
}).addTo(map); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment