Welcome back, map maker! In Module One, you learned how to put a basic map on a web page. In Module Two, you learned how to add data sources and layers. Your map can now show roads, buildings, and other information.
But here is the problem: a map with plain grey lines and black dots is boring. And more importantly, it does not tell you anything special. For example, if you show all the schools in a city, they all look the same. But what if you want to show which schools have more students? What if you want to show which roads are busy and which are empty?
That is where style and data-driven visualization come in. Style is how things look β their colour, size, and shape. Data-driven visualization means changing the style based on the data. In this module, you will learn how to make your maps beautiful and smart. You will learn how to change colours, sizes, and icons. You will learn how to make a map that tells a story.
We will keep using simple words and lots of examples. Letβs make your maps shine!
After you finish this module, you will be able to:
Chidi lived in Enugu. He loved maps. One day, his teacher gave the class a project: βMake a map of our school that shows where all the water taps are.β Chidi made a map with black dots for the taps. It was correct, but it was boring. His friend Ngozi looked at it and said, βI cannot tell which tap is working and which is broken.β
Chidi had an idea. He made working taps green and broken taps red. Suddenly, the map told a story. You could see at a glance which taps needed repair. His teacher was impressed. βChidi,β she said, βyou have learned the secret of style. A map with good style is a map that speaks.β
Chidi learned that style is not just about making things pretty. Style is about making information clear. A red dot jumps out at you. A green dot says βall is well.β A big circle says βthis is important.β A small circle says βthis is less important.β
Moral of the story: Style is a language. It tells your mapβs story without words.
Definition: Map style is how the things on your map look. It includes colour, size, shape, and transparency.
Why it is important: Style makes your map easy to understand. It helps people see patterns.
Simple explanation: Imagine you are drawing a picture. You choose a red crayon for fire and a blue crayon for water. That is style.
Real-life example: In a traffic app, red means heavy traffic and green means clear roads.
School example: In a school map, you might use a yellow star for the library and a blue circle for the toilets.
Home example: On a family map, you might use a heart for Grandmaβs house.
Nigerian example: A map of Nigeria might use green for agriculture areas and brown for desert areas.
Illustration:
+---------------------+ | STYLE | | [π΄] Red = Danger | | [π’] Green = Safe | | [π΅] Blue = Water | +---------------------+
Mini summary: Style is how things look on your map. Good style makes your map clear.
Definition: A point is a single location on the map. It can be a school, a market, or a house.
Why it is important: Points are the most common feature on maps. Styling them well is key.
Simple explanation: You can change the colour, size, and shape of a point. You can use a circle, a square, or an icon.
Real-life example: A map of restaurants might use a fork and knife icon for each restaurant.
School example: A map of your school might use a blue circle for classrooms and a red circle for offices.
Home example: A map of your house might use a star for your bedroom.
Nigerian example: A map of Lagos markets might use a yellow circle for each market.
Example code in OpenLayers:
new ol.style.Style({
image: new ol.style.Circle({
radius: 8,
fill: new ol.style.Fill({ 'red' }),
stroke: new ol.style.Stroke({ 'black', width: 2 })
})
})
Illustration:
Circle point: β Square point: β Star point: β Icon point: π
Mini summary: You can style points with different colours, sizes, and shapes.
Definition: A line is a path between two points. It can be a road, a river, or a boundary.
Why it is important: Lines show connections and routes.
Simple explanation: You can change the colour, thickness, and pattern of a line. A dashed line means something different from a solid line.
Real-life example: A map of a bus route uses a thick blue line to show the path.
School example: A map of your school might use a red line for the fire escape route.
Home example: A map of your street might use a black line for the road.
Nigerian example: A map of Nigeria might use a blue line for the River Niger.
Example code in OpenLayers:
new ol.style.Style({
stroke: new ol.style.Stroke({
'blue',
width: 4,
lineDash: [10, 10]
})
})
Illustration:
Solid line: ββββββββ Dashed line: ββ ββ ββ Thick line: ββββββββ Thin line: ββββββββ
Mini summary: You can style lines with colour, width, and dash patterns.
Definition: A polygon is a shape with many sides. It can be a park, a state, or a building.
Why it is important: Polygons show areas. They help you see regions and boundaries.
Simple explanation: You can change the fill colour, the border colour, and the transparency of a polygon.
Real-life example: A map of a flood zone uses a semi-transparent blue polygon.
School example: A map of your school might use a green polygon for the football field.
Home example: A map of your compound might use a brown polygon for the house.
Nigerian example: A map of Nigeria uses polygons for all 36 states.
Example code in OpenLayers:
new ol.style.Style({
fill: new ol.style.Fill({ 'rgba(0, 255, 0, 0.5)' }),
stroke: new ol.style.Stroke({ 'darkgreen', width: 2 })
})
Illustration:
+--------+ | Polygon| | ββββ | | ββββ | +--------+
Mini summary: You can style polygons with fill colour and border.
Definition: MapLibre uses a style file (a JSON file) to define how everything looks.
Why it is important: The style file is the heart of a MapLibre map. It controls all layers.
Simple explanation: The style file is like a recipe book. It lists each layer and says: βpaint this red, make that thick.β
Real-life example: A weather appβs style file might paint rain clouds dark blue.
School example: A school map style might paint classrooms yellow and offices pink.
Home example: A family map style might paint your house a special colour.
Nigerian example: A map of Lagos style might paint water blue and roads grey.
Example style snippet:
{
"id": "schools",
"type": "circle",
"paint": {
"circle-color": "red",
"circle-radius": 8
}
}
Illustration:
Style JSON
|
V
+---------------------+
| Layer: Schools |
| paint: red |
| radius: 8 |
+---------------------+
Mini summary: MapLibre styles live in a JSON file. The file controls all colours and sizes.
Definition: Data-driven styling means changing the style based on the data. For example, bigger circles for bigger values.
Why it is important: It turns your map into a tool for understanding. You can see patterns at a glance.
Simple explanation: Imagine a map of schools. If you make the circle bigger for schools with more students, you can see which schools are the largest.
Real-life example: A map of rainfall uses darker blue for areas with more rain.
School example: A map of exam results uses green for high scores and red for low scores.
Home example: A map of your familyβs favourite foods uses a bigger icon for the most loved food.
Nigerian example: A map of Nigeria uses different shades of green for different crop yields.
Illustration:
Data: 10 students -> small circle β Data: 50 students -> medium circle ββ Data: 100 students -> large circle βββ
Mini summary: Data-driven styling changes the look based on values. It makes your map smart.
Definition: Expressions are special instructions in MapLibre that let you calculate styles from data.
Why it is important: Expressions make your style file powerful. You can do maths and logic.
Simple explanation: An expression is like a formula in a spreadsheet. It says: βIf the value is greater than 50, use red. Otherwise, use blue.β
Real-life example: A map of temperature uses expressions to colour areas from blue (cold) to red (hot).
School example: A map of attendance uses expressions to colour classes with high attendance green.
Home example: A map of your chores uses expressions to colour finished chores green.
Nigerian example: A map of market prices uses expressions to show expensive items in red.
Example expression:
["interpolate", ["linear"], ["get", "population"],
0, "yellow",
1000, "orange",
10000, "red"
]
Illustration:
Value 0 -> yellow Value 1000 -> orange Value 10000 -> red
Mini summary: Expressions let you write rules for your styles. They make your map dynamic.
Definition: A label is text on the map. It names a place.
Why it is important: Labels help people know what they are looking at.
Simple explanation: You can show the name of a city, a school, or a market.
Real-life example: Google Maps shows the names of streets and cities.
School example: A school map shows βLibraryβ, βScience Labβ, and βFootball Fieldβ.
Home example: A family map shows βGrandmaβs Houseβ and βUncleβs Shopβ.
Nigerian example: A map of Nigeria shows βLagosβ, βAbujaβ, and βKanoβ.
Illustration:
β Abuja β Lagos β Kano
Mini summary: Labels are text that name places. They make your map readable.
Definition: An icon is a small picture used as a marker. It can be a pin, a star, or a custom image.
Why it is important: Icons make your map fun and easy to understand.
Simple explanation: Instead of a plain dot, you can use a picture of a school, a hospital, or a restaurant.
Real-life example: A map of hospitals uses a red cross icon.
School example: A school map uses a book icon for the library.
Home example: A family map uses a heart icon for Grandmaβs house.
Nigerian example: A map of Nigerian airports uses an aeroplane icon.
Illustration:
π« School π₯ Hospital π½οΈ Restaurant β½ Petrol Station
Mini summary: Icons are small pictures. They make your map friendly and clear.
Definition: A heatmap is a way to show where things are crowded. It uses colour to show density.
Why it is important: Heatmaps help you see hotspots. They are great for showing many points at once.
Simple explanation: Imagine dropping a thousand dots on a map. A heatmap turns those dots into a colourful cloud. Red means many dots. Blue means few dots.
Real-life example: A heatmap of a city shows where traffic jams happen most.
School example: A heatmap of your school shows where students gather most.
Home example: A heatmap of your house shows where the family spends most time.
Nigerian example: A heatmap of Lagos shows where accidents happen most.
Illustration:
π΅π΅π΅π΄π΄π΅π΅ π΅π΅π΄π΄π΄π΅π΅ π΅π΅π΅π΄π΅π΅π΅ Blue = few, Red = many
Mini summary: Heatmaps show density with colours. They are great for finding hotspots.
Definition: Static style never changes. Dynamic style changes based on data or user action.
Why it is important: Dynamic styles make your map interactive and smart.
Simple explanation: A static style is like a painting. A dynamic style is like a video.
Real-life example: A weather map changes colours as the weather changes. That is dynamic.
School example: A school map might change colours when you click a button to show exam results.
Home example: A family map might change colours on birthdays.
Nigerian example: A map of Nigeria might change colours on Independence Day.
Table: Static vs Dynamic
| Feature | Static Style | Dynamic Style |
|---|---|---|
| Changes? | No | Yes |
| Based on data? | No | Yes |
| Example | Fixed red dot | Colour changes with value |
Mini summary: Static style stays the same. Dynamic style changes. Dynamic is smarter.
Definition: A colour scale is a set of colours that go from low to high. For example, yellow to red.
Why it is important: Colour scales help you see differences quickly.
Simple explanation: You use an expression to say: βIf the value is 0, use yellow. If 50, use orange. If 100, use red.β
Real-life example: A temperature map uses a colour scale from blue to red.
School example: A map of exam scores uses a colour scale from red (low) to green (high).
Home example: A map of your savings uses a colour scale from red (low) to green (high).
Nigerian example: A map of rainfall in Nigeria uses a colour scale from light blue to dark blue.
Illustration:
0 -> π¨ Yellow 50 -> π§ Orange 100 -> π₯ Red
Mini summary: Colour scales show values with colours. Expressions make them work.
Definition: Label style includes font, size, colour, and halo (outline).
Why it is important: Labels must be easy to read. If they are too small or the wrong colour, they are useless.
Simple explanation: You can add a white outline around text so it shows on any background.
Real-life example: Street signs use big white letters on a green background.
School example: A school map uses bold black text for building names.
Home example: A family map uses big red letters for βHOMEβ.
Nigerian example: A map of Nigeria uses white text with a black outline for state names.
Illustration:
Bad label: dark blue on black (hard to read) Good label: white text with black halo (easy to read)
Mini summary: Good label style makes text readable. Use halos and contrast.
Definition: You can give each layer its own style.
Why it is important: Different layers need different looks. Roads should look different from rivers.
Simple explanation: You create a style for each layer and attach it.
Real-life example: A map has blue lines for rivers and grey lines for roads.
School example: A school map has green polygons for fields and brown polygons for buildings.
Home example: A family map has red dots for relatives and blue dots for friends.
Nigerian example: A map of Nigeria has green polygons for forests and yellow polygons for savannah.
Illustration:
Layer: Roads -> Style: grey, thick Layer: Rivers -> Style: blue, thin Layer: Parks -> Style: green, fill
Mini summary: Each layer can have its own style. This makes your map clear.
Definition: You can combine all the styling techniques you learned.
Why it is important: A real map uses many styles together.
Simple explanation: Start with a base map. Add styled roads. Add styled points for schools. Add labels. Add a heatmap. Turn some layers on and off.
Real-life example: A city planning map shows roads, buildings, parks, and population density all at once.
School example: A school map shows classrooms, fields, water points, and a heatmap of student movement.
Home example: A family map shows homes, shops, and a heatmap of favourite places.
Nigerian example: A map of Abuja shows roads, government buildings, markets, and a heatmap of traffic.
Illustration:
+---------------------+ | Labels | +---------------------+ | Heatmap (traffic) | +---------------------+ | Schools (points) | +---------------------+ | Roads (lines) | +---------------------+ | Base Map | +---------------------+
Mini summary: Combining styles makes a beautiful, smart map. You are now a map artist!
| Word | Simple Definition |
|---|---|
| Style | How something looks on the map. |
| Fill | The inside colour of a shape. |
| Stroke | The border or outline of a shape. |
| Radius | The size of a circle point. |
| Label | Text that names a place. |
| Icon | A small picture used as a marker. |
| Heatmap | A colour cloud showing density. |
| Expression | A rule that calculates a style. |
| Data-driven | Style that changes based on data. |
| Colour scale | A set of colours from low to high. |
| Halo | An outline around text. |
| Transparency | How see-through something is. |
new ol.style.Style().image property with a circle or icon.fill colour and stroke.radius for size.paint section, use an interpolate expression.
Start
|
V
Choose data property (e.g., population)
|
V
Decide colour scale (yellow -> red)
|
V
Write expression
|
V
Add to style layer
|
V
See smart map! π
1800s - First heatmaps (cholera) 1970s - Colour scales in cartography 2005 - Google Maps styling 2010 - Data-driven styling grows 2015 - Vector tiles enable dynamic styles 2020 - MapLibre expressions 2024 - You learn to style!
| Feature | Style Property | What it does |
|---|---|---|
| Point | radius | Size of the point |
| Point | fill | Inside colour |
| Line | stroke width | Thickness of the line |
| Line | lineDash | Dashed pattern |
| Polygon | fill | Inside colour |
| Polygon | stroke | Border colour |
| Question | OpenLayers | MapLibre |
|---|---|---|
| How do you style? | JavaScript code | JSON style file |
| Dynamic styling? | Yes, with functions | Yes, with expressions |
| Heatmaps? | Yes | Yes |
| Labels? | Yes | Yes |
| Icons? | Yes | Yes |
Lesson 1: Style is how things look on your map.
Lesson 2: You can style points with colour, size, and shape.
Lesson 3: You can style lines with colour, width, and dash.
Lesson 4: You can style polygons with fill and border.
Lesson 5: MapLibre uses a style file (JSON) for all styling.
Lesson 6: Data-driven styling changes based on data.
Lesson 7: Expressions are rules for styles in MapLibre.
Lesson 8: Labels name places on the map.
Lesson 9: Icons are small pictures for markers.
Lesson 10: Heatmaps show density with colours.
Lesson 11: Static style never changes. Dynamic style does.
Lesson 12: Colour scales show values from low to high.
Lesson 13: Good label style makes text readable.
Lesson 14: Each layer can have its own style.
Lesson 15: Combining styles makes a beautiful, smart map.
In this module, you learned how to make your maps beautiful and smart. You discovered how to style points, lines, and polygons in OpenLayers. You learned how MapLibre uses a JSON style file to control everything. You explored data-driven styling and expressions, which let your map change based on data. You learned how to add labels and icons, and how to create heatmaps. You also learned the difference between static and dynamic styles, and how to use colour scales. Finally, you combined all these techniques to make a rich, informative map. You are now a map artist!
Match the word to its meaning.
| Word | Meaning |
|---|---|
| 1. Fill | A. Text that names a place |
| 2. Stroke | B. Inside colour of a shape |
| 3. Label | C. A colour cloud showing density |
| 4. Heatmap | D. Border or outline of a shape |
| 5. Expression | E. A rule that calculates a style |
Answers: 1-B, 2-D, 3-A, 4-C, 5-E
Title: Design a Colour Scale for Your School
Instructions: In groups of 3, choose a data property for your school (e.g., number of students per class). Create a colour scale with 5 colours. Explain what each colour means. Draw a sample map using the scale. Present to the class.
Title: Style Your Own Points
Instructions: Create a map with three points. Use a different colour and size for each point. Add a label for each point. Save and show your family.
Title: A Data-Driven Map of Your Class
Instructions: Create an HTML file with a MapLibre or OpenLayers map. Add a vector layer with points for each studentβs home. Use a colour scale based on the distance from school. Add labels with student names. Add a heatmap layer showing where students live. Save and present to the class.
Task: Write a short paragraph (5 sentences) explaining what you learned about map styling and data-driven visualization. Then, list three things you found easy and one thing you found hard.
In Module Four, we will learn about interaction and map controls. We will make our maps respond to clicks, hovers, and other actions. We will add popups, select features, and draw shapes. To get ready, make sure you:
See you in Module Four! π
End of Module Three Β· Certified OpenLayers/MapLibre User