Skip to content

Instantly share code, notes, and snippets.

@pedromcunha
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save pedromcunha/e1506d3cd1b27b77095f to your computer and use it in GitHub Desktop.

Select an option

Save pedromcunha/e1506d3cd1b27b77095f to your computer and use it in GitHub Desktop.
Instantiate the CartoDB Map
cartodb.createLayer(map, {
user_name: 'dmonay',
type: 'cartodb',
sublayers: [{
sql: "SELECT * FROM bathymetry_layers",
cartocss: "#bathymetry_layers{ polygon-fill: #598cdb;polygon-opacity: 0.2;line-color: #FFF;line-width: 0;line-opacity: 1;}"
},{
sql: "SELECT * FROM pm25_na",
cartocss: $('#pm25_na').html().format('pm25_2000'),
interactivity: "cartodb_id, the_geom, pm25_2000, pm25_2001, pm25_2002, pm25_2003, pm25_2004, pm25_2005, pm25_2006, pm25_2007, pm25_2008, pm25_2009, pm25_2010, pm25_2011, pm25_2012, country"
},{
sql: "SELECT * FROM who_georeferenced_clean",
cartocss: $('#cities').html().format('city_station'),
interactivity: "city_station, pm_2_5, country"
}]
}).done(function(layer) {
// add the layers to our map
map.addLayer(layer);
sublayer_country = layer.getSubLayer(1);
sublayer_country.setInteraction(true);
sublayer_city = layer.getSubLayer(2);
sublayer_city.setInteraction(true);
createSelector(sublayer_country);
createSelector(sublayer_city);
sublayer_city.hide();
//create infowindow
sublayer_city.infowindow.set('template', $('#infowindow_template').html()).on('error', function() {
console.log("some error occurred");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment