I am doing a choropleth map using leaflet and JSON data. I got a clean tutorial in leaflet site. In that tutorial the used us-states.js JSON file where the choropleth was based on the feature.properties.density feature of the JSON if I am not wrong. If we see the JS file we can found there is a field called "ID" which is state id. I have a database where I have 5 different categories of data based on state ID. Categories are population, density, male_population, female_population, literacy_rate. I am calling those data through ajax and get a GeoJSON data state-wise as follows (Its a dummy data).


I want to integrate this data as choropleth value. when I call on literacy function the variation of color will be based on literacy_rate data. I can make the changes in getcolor function category wise.


  • you have 2 questions here, how to integrate the two data? and how to color map dynamically?. You should split these into two separate questions.
    – neogeomat
    May 20, 2014 at 6:18
  • If I get one answer I will be pleased. May 21, 2014 at 8:02

1 Answer 1


The literacy function should be like this

function literacy_function(){
    return {color:getColor(feature.properties.literacy_rate),
           other_options: options

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.