Last active
October 16, 2015 21:53
-
-
Save michellechandra/0058364f950d7b38c36c to your computer and use it in GitHub Desktop.
CartoDB Unsanitized Infowindow using CreateVis
This file contains hidden or 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> | |
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> | |
<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> | |
</body> | |
<script type="infowindow/html" id="infowindow_template"> | |
<div class="cartodb-popup"> | |
<a href="#close" class="cartodb-popup-close-button close">x</a> | |
<div class="cartodb-popup-content-wrapper"> | |
<div class="cartodb-popup-content"> | |
<!-- content.data contains the field info --> | |
<h4>Custom Content</h4> | |
</div> | |
</div> | |
<div class="cartodb-popup-tip-container"></div> | |
</div> | |
</script> | |
<script src="http://libs.cartodb.com/cartodb.js/v3/3.15/cartodb.js"></script> | |
<script async src="http://platform.twitter.com/widgets.js" charset="utf-8"></script> | |
<script> | |
function main() { | |
cartodb.createVis('map', 'http://documentation.cartodb.com/api/v2/viz/7eb2096a-51d9-11e3-89a7-5404a6a683d5/viz.json', { description: true, search: true, shareable: true }) | |
.on('done', function(vis,layers) { | |
var layer = layers[1].getSubLayer(0); | |
layer.infowindow.set('template', $('#infowindow_template').html()); | |
layer.infowindow.set('sanitizeTemplate', 'false'); | |
layer.on('error', function(err) { | |
console.log('error: ' + err); | |
}); | |
}).on('error', function() { | |
console.log("some error occurred"); | |
}); | |
} | |
window.onload = main; | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment