1

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.

  • 1
    What specifically is wrong? Please check out these guidelines for posting a question! gis.stackexchange.com/tour – jbchurchill Apr 1 '16 at 18:10
  • Hi, i edited the post to clarify what i am needing. Thank you – Jeff Reed Apr 2 '16 at 23:00
1

CartoDB allows you to update your datasets via synced tables. Here you will find a blog post on how to make real-time visualizations with synced tables. In relation to your code, you forget several things (the basemap, for example). I have created a working example, but as you pointed out it is a static map. But I believe it will help you to check what you missed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.