mercredi 10 décembre 2014

Can I include data from multiple rows in CartoDB infowindow?


I have a visualization in CartoDB of a set of data points in table pointlayer. I am using cartodb.js and have a nice map for browser consumption.


When a user clicks on a point, I'd like to run a sql query that returns multiple rows relating to the clicked-upon point, and I'd like to put all that into the infowindow.



select column_a column_b, etc
from anothertable
join pointlayer
on pointlayer.point_id = anothertable.point_id
where
pointlayer.point_id = <cartodb_id of clicked on point>


anothertable may have 0 or more rows for any point_id


Is this possible with infowindows? Looks to me like the answer is probably no: they are designed for a single row. I suspect that I need to find a solution other than using CartoDB's infowindow (e.g. using Leaflet's popup), but I thought I would ask.


An answer here on stackexchange suggests to "actually query the table and get back all data." It doesn't state that the infowindow itself can be used to display it...though I could be reading it incorrectly.


Thanks.





Aucun commentaire:

Enregistrer un commentaire