0

I am trying to create a choropleth map for a school project I am working on. Based off user input, I will create a csv file that I will then upload to CartoDB using their Import API. By setting the create_vis=true option, CartoDB will automatically make a map using that table. By default, however, this map is of the Simple type. Is there any way to make this a choropleth type map programatically?

I understand that you can do this in the wizards editor in the UI, but I am trying to do all of this at runtime (so that it is dynamic).

1

At the end of the day, what the Wizard does when you select choropleth is changing the CartoCSS properties of the layer. So first you have to create a CartoCSS style by categories/proportions and then set your layer to this style using setCartoCSS() method. You have three ways to achieve this, check this tutorial about how to do it.

  • Since I am doing this dynamically, the thresholds for the choropleth depend on the current data. How can I set appropriate thresholds depending on the data using setCartoCSS()? CartoDB seems to set these values for you depending on the data if you do it through the Wizard. Is there a way to do this programatically? – user3699999 Apr 28 '16 at 1:10
  • If what you want is to change the ranges/proportions of your choropleth map, you can create a layer selector (a dropdown menu, for instance). Here you have a working example about selecting different classification methods on a choropleth map. And here you have another about selecting different Torque styles. – ramiroaznar Apr 28 '16 at 7:41

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.