I have successfully created a toggle map following the instructions in this tutorial http://developers.cartodb.com/tutorials/toggle_map_view.html.

The toggle map is linked to a map in my cartodb account that has two layers in the UI - the first layer shows colored points in a choropleth view, the second layer shows a sort of cluster view so that I can have numbers appear where there are large clusters. I have have my buttons set up in the toggle map so that you can see points from different years - 2011, 2012, 2013, and 2014. When I click on a year, say 2011, all the points from the first layer (choropleth layer) that are from 2011 appear and all others disappear, so the buttons are selecting correctly for my first layer. But the buttons don't filter through any of the points in the second layer (the cluster layer with the numbers appearing for clusters). This is providing inaccurate numbers for my clusters when I'm clicking on different years. For example, in one area of the map, there are 37 points for all the years (so when all points are visible the cluster layer accurately says there are 37 points there). But when I select 2011, there are 0 points in that region for 2011, and it still says 37 on the cluster layer.

Is there a separate way to set up the toggle map so that it will interact with and select from all layers in my UI?

  • I am having a hard time pinpointing exactly where you are having a problem. It can help if you can share portions of code where you are seeing problems or other examples of intended functionality. In lieu of any of those, the best I can say is, have you taken a look at this? bl.ocks.org/javisantana/6493211 – andrewxhill Feb 19 '14 at 13:54
  • @andrewxhill I've created a map using the UI that has one layer as category visualization and another layer as cluster visualization (like this cdb.io/1fe0PPs). When I use this API for a cartodb.js map with toggle buttons by year, the buttons only select points from the category layer and keeps all numbers from the cluster layer. Example: if I click the 2011 button, no points appear over Damascus (which is correct, as there are no 2011 points there) but it still says 37 on the cluster layer. So the toggle buttons aren't linked to the cluster layer. – user25917 Feb 19 '14 at 19:17
  • @andrewxhill Sorry I can't attach the actual html file for the cartodb.js map so you can see the issue when you click the buttons, but I can email the file to you if that would be helpful – user25917 Feb 19 '14 at 19:18
  • @andrewxhill Actually, if you download the html file from this dropbox link and open it in your browser, you should see the problem I describe dropbox.com/s/vrsejciu8k0rayz/test%20Jan%2019.html – user25917 Feb 19 '14 at 19:37

Your Answer

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

Browse other questions tagged or ask your own question.