1

How do I create an info window where you can scroll through and see features for different points that have the same geometry? I am making a map of newspapers. For example, there's a cluster of 6 at New Orleans and 272 at New York. My info window only shows info for one newspaper even though there are obviously many more. How do I fix this?

0

You'd need to use CartoDB.js (link course)

There, you'd need to work with infowindow model and its templates.

If your scenario is with public datasets, you could use the next examples:

The key is to set a template calling the API SQL too. There, you could build that infowindow as you want.

Example:

 function main() {

    cartodb.createVis(map, 'youviz.json')
     .on('done', function(vis,layers) {
      var infowindow = layers[1].getSubLayer(0).infowindow
      infowindow.set('template', _.debounce(function(data) {
        var clickPosLatLng = this.model.get('latlng');
        var url = //Your sql query
        $.get(url, function(data) {
          var em = $('<div>');
          _.map(data.rows, function(r) { 
            var element = $('<li><a href="#" onClick="return false;">' + r.description + '</a></li>');
              em.append(element);
          });
          $('#mylist').append(em);
        });

        return $('#infowindow_template').html();
  }

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.