-2

I have been working from a sample on point clustering from cartodb. I would like to have an infowindow show when someone hovers over a series of points. This infowindow will display a different template if the points_count is greater than one. Any pointers on why in this case the info window is not showing up at all? When i do have the info window as part of the layer definition, i.e before calling addInteraction, is does show the default infowindow, but i want to have custom info windows based on the counts in the cluster.

https://gist.github.com/jmwenda/36579d3858fa84ed8f840db70861afa2#file-index-html-L97

http://bl.ocks.org/jmwenda/raw/36579d3858fa84ed8f840db70861afa2/

1

So the issue I think is that your creating a new info window each time you hover over a feature

hovers[layer] = 1; var infowindow = new cdb.vis.Vis.addInfowindow(map, markerLayer.getSubLayer(layer), ['cartodb_id']); $('#map').append(infowindow.render().el); if(_.any(hovers)) { $('#map').append(infowindow.render().el); }

Instead what you want to do is to create the template in such a way that it will render differently when you have >1 point. You can set a flag in javascript before rendering the template as described here

https://stackoverflow.com/questions/8548943/how-to-handle-an-if-statement-in-a-mustache-template

and have two conditionals in the pop up template.

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.