Skip to content

Instantly share code, notes, and snippets.

@iriberri
Created September 26, 2014 08:56
Show Gist options
  • Save iriberri/799bfa2b278923e8d9d0 to your computer and use it in GitHub Desktop.
Save iriberri/799bfa2b278923e8d9d0 to your computer and use it in GitHub Desktop.
infowindow hidden
<!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;
}
.tweetwindow { position: relative;
width: 350px;
background-color: white;
}
.cartodb-popup-close-button {
position: absolute;
top: -3px;
right: -11px;
width: 26px;
height: 26px;
background: url('http://libs.cartodb.com/cartodb.js/v3/themes/img/light.png') no-repeat 0 -23px;
text-indent: -9999px;
font-size: 0;
line-height: 0;
opacity: 1;
text-transform: uppercase;
z-index: 3;
}
.cartodb-popup-tip-container {
position: absolute;
bottom: -3px;
left: 23px;
width: 16px;
height: 14px;
background: url('http://libs.cartodb.com/cartodb.js/v3/themes/img/light.png') no-repeat -23px -7px;
text-indent: -9999px;
font-size: 0;
line-height: 0;
opacity: 1;
z-index: 3;
}
blockquote {
display: hidden;
}
.cartodb-popup-content {
min-height: 80px;
}
</style>
<link rel="stylesheet" href="http://libs.cartodb.com/cartodb.js/v3/themes/css/cartodb.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://libs.cartodb.com/cartodb.js/v2/themes/css/cartodb.ie.css" />
<![endif]-->
</head>
<body>
<div id="map"></div>
</body>
<script type="infowindow/html" id="infowindow_template">
<div class="tweetwindow" id="tweet">
<a href="#close" class="cartodb-popup-close-button close">x</a>
<div class="cartodb-popup-content">
</div>
</div>
</script>
<script src="http://libs.cartocdn.com/cartodb.js/v3/cartodb.js"></script>
<script async src="http://platform.twitter.com/widgets.js" charset="utf-8"></script>
<script>
function main() {
cartodb.createVis('map', '< VIZ JSON URL>', { description: true, search: true, shareable: true })
.on('done', function(vis,layers) {
var layer = layers[1].getSubLayer(0);
layer.infowindow.set('template', function(data) {
if(data.content.data['twitter_id'] !== undefined) {
if (data.content.data['twitter_id'].length > 17){
content = $('#infowindow_template').html();
div = $('<div>').html(content);
tweet = $(div).find(".cartodb-popup-content")[0];
twttr.widgets.createTweet(data.content.data.twitter_id, tweet);
return div;
}
} else {
empty_geom_msg = $('<div>').html("Geometry does not contain data. <br>");
return empty_geom_msg;
}
});
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