Open up Mapbox Studio Classic and start a New Project. Click Create at the bottom of the prompt to start a new project.
To start, remove everything in the stylesheet except the Map selector at the top. Click “Save as” and select a location to save the project – this will cause your style changes to show up on your map.
Now that you’ve got a white map background, you want to define the colors of your lovely rainbow. Here are six bright colors – red, orange, yellow, green, blue, and purple – but you can pick whichever colors you’d like for your rainbow. Using variables in CartoCSS, we can define these colors right at the top of our style and use them throughout:
With these variables, wherever we use @color1 in the stylesheet, it will always represent #ED1C24. This is super handy, especially if you decide you want to change the colors later.
You are going to do something maybe counter-intuitive with this map: instead of creating rainbow borders around the land features, you’re going to create rainbow borders around the water features. This will allow you to have nice-looking coastal boundaries while showing off the Great Lakes and other large inland water bodies.
Below the Map and color variables, create a selector for #water and give it a blue polygon-fill:
Press Save and the map will regenerate. Now you can see that when you style the water instead of the land, the land is still clearly visible!
Now you can add the rainbow borders to the water. The technique for doing this is to create several styles for the border, each one slightly smaller that will get layered on top of the next. Inside the #water selector, add the styling for each colored border using attachments:
With this CartoCSS, the red border is 14 pixels, the orange border is 12 pixels, and so on up to the white border, which is 2 pixels. This creates a cascading rainbow effect on the borders of the land features, even though it’s secretly around the water bodies!
Hooray! Now we have a lovely world map with rainbow borders.
You can find the full style on GitHub here. Be sure to show us your own rainbow maps by tweeting @Mapbox. Happy mapping! #LoveWins