I am attempting to create a choropleth using the actual polygons included in any one of the base Mapbox maps.
Specifically, I have a geojson structure with a data specific property in the properties object and I'd like to have a different color land fill for all countries, depending on where the fall on a certain scale.
So far the Map class appears to color all land at once:
Map {
background-color: red;
}
And I can't seem to do this:
Map {
[myVar > 0.4] { background-color: pink; }
[myVar <= 0.4] { background-color: green; }
}
I've tried to use my own polygons from my GeoJSON file but they aren't nearly as clean as the Mapbox polygons, even at the highest resolution I've found. Additionally, I want to be able to overlay the labels and other markers that Mapbox base styles have, just on top of my cholorpleth.
I've also tried to color the #admin[admin_level=2][maritime=0]
regions, but they don't appear to be polygons and result in something like this:
Thanks in advance!
Assuming Tilemill 0.10.1 and using this GeoJSON (imported as countrydata
) and this CartoCSS:
#countrydata {
line-color:#594;
line-width:0.5;
polygon-opacity:1;
polygon-fill:#ae8;
[2014_pop>=100000] {polygon-fill:@yellow;}
[2014_pop>=10000000] {polygon-fill:@orange;}
[2014_pop>=20000000] {polygon-fill:@pink;}
[2014_pop>=200000000] {polygon-fill:@red;}
}
I get:
Notice how color is informed by the 2014_pop
property. I would recommend naming properties with a starting letter so that the editor doesn't get confused.