Styling data

TileMill is no longer in active development. For our most up-to-date map design tool, check out Mapbox Studio.
If you've found yourself on this page, we're assuming you've

TileMill uses a language called CartoCSS to determine the look of a map. Colors, sizes, and shapes can all be manipulated by applying their relative CartoCS parameters in the stylesheet panel to the right of the map. Read the CartoCSS manual for a more detailed introduction to the language.

In the previous crash course section on Importing data, we added an earthquake point layer using the “Save & Style” button. This button automatically added several styling parameters to your stylesheet and gave them an initial value. Styling

  1. #earthquakes
    This is the layer to which the styles are applied.

  2. marker-width
    This determines the size of the markers, in pixels. If marker-height is not specified, it is given the same value, resulting in a circle marker. You can experiment with changing this by typing in a different number.

  3. Click the “Save” button to save your project and trigger the map preview to update. Save project

  4. marker-fill
    This is the color of the inside of the marker. There are two methods for changing color values. You can either type in a new value, or you can use the color swatches at the bottom of the CartoCSS panel. Try changing the marker color by clicking the light red swatch and selecting a new color. Styling

  5. Click “Save” in the color picker to see your changes. Notice the corresponding color value is updated in the CartoCSS.

  6. marker-line-color
    This is the color of the border of the marker. This time try changing the color by replacing the hex value #813 with #000, the code for black.

  7. Click “Save”. Notice that the color swatch is updated with the new color.

  8. marker-allow-overlap
    This allows markers to be placed on top of each other. If this is not specified or set to false, potentially overlapping markers will not be displayed.

Conditional styles

Conditional CartoCSS styles allow you to change the appearance of the points on your map based on attributes in the data. Here we will customize the earthquake points based on the magnitude of the quake.

  1. Review the available data for the layer in the feature inspector. Feature inspector
  2. Find the column called Magnitude and examine the range of values. This will help you decide how to scale the points. Feature inspector
  3. Add the following CartoCSS rule to the bottom of your stylesheet. This CartoCSS rule sets a larger marker-width for features that have a larger Magnitude value.

     #earthquakes {
       [Magnitude >= 2.5] { marker-width:6; }
       [Magnitude >= 3]   { marker-width:8; }
       [Magnitude >= 3.5] { marker-width:10; }
       [Magnitude >= 4]   { marker-width:12; }
       [Magnitude >= 4.5] { marker-width:14; }
       [Magnitude >= 5]   { marker-width:16; }
       [Magnitude >= 5.5] { marker-width:18; }
       [Magnitude >= 6]   { marker-width:20; }
     }
    
  4. Click “Save” to view your changes.
  5. Use the map preview to confirm that the style is working. Adjust the CartoCSS rule until you are satisfied. Conditional style

These are just a few of the basic parameters for styling point data. For a comprehensive look at styling possibilities, checkout the CartoCSS reference section in TileMill and online. Styling

Misson complete! Next up