I have tried to figure out why the layer is not showing up on the map. My code is as follows.

var markersLayerSource = {
    user_name: 'someaccount',
    type: 'cartodb',
        sublayers: [{
            sql: baseSql,
            https: 'force https',
            cartocss: cartoCss,
            interactivity: 'cartodb_id'

        cartodb.createLayer(map, markersLayerSource, {https: true})
            .on('done', function (layer) {
            layer.getSubLayer(0).on('featureOver', function(e, pos, pixel, data) {
                // print data to console log
                console.log("Event #" + data.cartodb_id + ", name " + data.name + ", max population: " + data.pop_max);
            //cdb.vis.Vis.addInfowindow(map, layer.getSubLayer(0), ['cartodb_id']);

Any one with pointers on why i specifically need to have cdb.viv.Vis.addInfowindow inorder for the layer to show up on the map? Am I doing something wrong if one needs to render without the addinfowindow?

1 Answer 1


Please check all the variables you have introduced within your markerLayerSource (the console will tell you what is wrong anyway). I have replicated your code in this working example. But I have used a different methodology to add the tooltip:

var tooltip = layer.leafletMap.viz.addOverlay({
    type: 'tooltip',
    layer: layer,
    template: '<div class="cartodb-tooltip-content-wrapper"> <div class="cartodb-tooltip-content"><h3>{{name}}</h3><p>{{pop_max}} inhabitants</p></div></div>', 
    width: 200,
    position: 'bottom|right',
    fields: [{ name: 'name' }, { pop_max: 'pop_max' }]


So first, check that all your variables are well declared (baseSql and cartoCss) and secondly, try to use this methodology to add the tooltip. This is a screenshot of the result:

enter image description here

  • Thanks this really helps. I did use the same base and using the queries as follows but there are some javascript issues with the points to some of the some layers. Any idea on what I am doing wrong? bl.ocks.org/jmwenda/raw/b472b0a932fc5b895a5e59dadac18192 Commented Aug 10, 2016 at 1:17
  • There is nothing showing in the console and also I am not sure what I am looking for. Could you please be more specific? Commented Aug 10, 2016 at 7:50
  • Sorry, when hovering the different layers, the infowindows pop up in a haphazard manner. I.e hover the cursor on some of the points and infowindows are triggered at the wrong place on not shown at all. Commented Aug 10, 2016 at 14:35
  • bind is a Leaflet method, if you have a look at my block I have used a different (CARTO) methodology. Commented Aug 10, 2016 at 14:43
  • Thanks a million totally missed that! Changed to using .on but still having infowindows not appearing for some, the green point fails to trigger at all at time while the red point triggers several infowindows. Also depends on which is triggered first. Commented Aug 10, 2016 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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