I am trying to create a runtime visualization for a CartoDB map and I am quite the trouble with doing it. I have gone over the documentation and cannot get the code to work correctly at all unless it is a static vis. We are wanting to use the runtime code because our data is ever updating and we want the map to update with the code. Here is what I have thus far.
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.15/themes/css/cartodb.css" />
<div id="map"></div>
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.15/cartodb.js"></script>
<script>
function main() {
cartodb.createLayer(map, {
user_name: 'edwinorange',
type: 'cartodb',
sublayers: [{
sql: "SELECT * FROM carto_db",
cartocss: '#carto_db { marker-fill: red; }'
}]
})
.addTo(map)
.done(function(layer) {
layer.createSublayer({
sql: "SELECT * FROM carto_db",
cartocss:'#carto_db {marker-fill: #F0F0F0;}'
});
layer.getSubLayer(0).setSQL("SELECT * FROM carto_db LIMIT 10");
});
}
window.onload = main;
</script>
After writing this code and following along with the cartoDB documentation I don't get an output in the browser or any JS errors in the console. My hope is that I can receive support on how to correctly write the code that will create a runtime visualization of a map from our dataset.
I am not sure if what I am wanting is possible or not. We can create a static visualization however, when using the cartodbJS I am having no luck on creating a carto map from scratch using the above code.