Welcome back, map maker! In Module One, you learned how to put a simple map on a web page. You saw how to move it and zoom it. You also learned that maps are made of small pictures called tiles.
But a map with only land and water is just the beginning. Real maps show roads, buildings, schools, markets, rivers, and much more. How do we add all that? We use something called data sources and layers.
In this module, you will learn how to add different kinds of information to your maps. You will load data from the internet, from files on your computer, and even create your own data. You will learn how to stack layers so that your map shows exactly what you want. By the end, you will be able to make a rich, useful map β not just a plain one.
We will keep using simple words and lots of examples. Letβs dive in!
After you finish this module, you will be able to:
Amina lived in Kano. She loved helping her mother at the market. One day, her mother asked her to draw a map of the market so that visitors could find their way. Amina drew the main road and the market gate. But when she showed it to her mother, her mother said, βWhere are the shops? Where is the fish section? Where are the toilets?β
Amina realised her map was too plain. It had only the road and the gate. It needed more information. She went back and added small pictures for each shop. She added a symbol for the fish section and another for the toilets. She even added a layer showing where the water taps were. Now the map was useful!
Her mother smiled and said, βNow this is a map that people can use.β Amina learned that a map becomes powerful when you add layers of information. Each layer tells a different story. And each layer comes from a source.
Moral of the story: A map with only land and water is like a cake with no icing. Layers and data sources add the flavour.
Definition: A data source is the place where your map gets its information. It could be a website, a file, or a service.
Why it is important: Without a source, your map has nothing to show. It would be blank.
Simple explanation: Think of your map as a television. The data source is the TV station. Without a station, you see nothing.
Real-life example: OpenStreetMap is a free data source that gives map tiles to millions of websites.
School example: Your school library is a source of books. A map source is a source of map data.
Home example: A borehole is a source of water. A map source is a source of map pictures.
Nigerian example: The Nigerian Meteorological Agency is a source for weather data used in maps.
Illustration:
+---------------------+
| DATA SOURCE |
| [π] Website |
| [π] File |
| [βοΈ] Service |
+---------------------+
|
V
Your Map Gets Data
Mini summary: A data source is where map information comes from. It can be online or on your computer.
Definition: Raster data is map data made of tiny coloured squares called pixels. It looks like a photograph.
Why it is important: Raster tiles are the most common way to show base maps. They are simple and fast.
Simple explanation: Imagine a photo of a city from a satellite. That is raster data. Each small square has a colour.
Real-life example: Satellite images on Google Earth are raster data.
School example: A scanned drawing of a map is raster data.
Home example: A photograph on your phone is raster data.
Nigerian example: Satellite images of the Niger Delta showing oil spills are raster data.
Illustration:
+----+----+----+ | π© | π© | π¦ | +----+----+----+ | π© | π« | π¦ | +----+----+----+ | π« | π« | π¦ | +----+----+----+ Raster: each square is a pixel.
Mini summary: Raster data is made of pixels. It looks like a picture.
Definition: Vector data is map data made of points, lines, and polygons (shapes). It is not a picture; it is a set of instructions.
Why it is important: Vector data can be styled, searched, and changed easily. It stays sharp when you zoom in.
Simple explanation: A dot for a school is a point. A road is a line. A park is a polygon.
Real-life example: The roads in a navigation app are vector lines.
School example: A map of your school with a dot for each classroom is vector data.
Home example: A drawing of your house with lines for walls is vector data.
Nigerian example: A map showing the boundaries of all 36 states is vector data (polygons).
Illustration:
Point: β’ (school) Line: ββββ (road) Polygon: β (park)
Mini summary: Vector data is made of points, lines, and shapes. It is sharp and flexible.
Definition: We compare the two types of data.
Why it is important: Knowing the difference helps you choose the right data for your map.
Simple explanation: Raster is like a photo. Vector is like a drawing.
Table: Raster vs Vector
| Feature | Raster | Vector |
|---|---|---|
| Made of | Pixels | Points, lines, polygons |
| Looks like | Photo | Drawing |
| Zoom quality | Gets blurry | Stays sharp |
| File size | Can be large | Usually smaller |
| Best for | Satellite images | Roads, boundaries |
Mini summary: Raster is pixels. Vector is shapes. Both are useful.
Definition: OpenStreetMap (OSM) is a free map of the world made by volunteers. You can use its tiles in your map.
Why it is important: OSM is free and covers the whole world, including Nigeria.
Simple explanation: You just tell OpenLayers or MapLibre to use the OSM tile source. The map appears.
Real-life example: Many apps use OSM tiles as their base map.
School example: A school project can use OSM to show the location of the school.
Home example: You can make a map of your neighbourhood using OSM tiles.
Nigerian example: OSM has detailed maps of Lagos, Abuja, and Kano.
Step-by-step in OpenLayers:
new ol.layer.Tile({
source: new ol.source.OSM()
})
Step-by-step in MapLibre: MapLibre uses a style URL. The demo style often includes OSM data. You can also use a style that points to OSM tiles.
Illustration:
+---------------------+ | OSM TILE SOURCE | | [π] [π] [π] | | World coverage | +---------------------+
Mini summary: OpenStreetMap is a free tile source. You can add it in one line of code.
Definition: GeoJSON is a simple file format for vector data. It uses text to describe points, lines, and shapes.
Why it is important: GeoJSON is easy to read and write. You can create your own data files.
Simple explanation: A GeoJSON file looks like a list of places with their coordinates.
Real-life example: Many open data websites give you GeoJSON files to download.
School example: A teacher can create a GeoJSON file of all the classrooms in the school.
Home example: You can make a GeoJSON file of your favourite spots in your neighbourhood.
Nigerian example: A GeoJSON file could show the locations of all primary schools in a state.
Example GeoJSON:
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [8.6753, 9.0820]
},
"properties": {
"name": "Abuja"
}
}
How to load in OpenLayers:
new ol.layer.Vector({
source: new ol.source.Vector({
url: 'my-data.geojson',
format: new ol.format.GeoJSON()
})
})
Mini summary: GeoJSON is a text file for vector data. You can load it into your map.
Definition: Vector tiles are like raster tiles, but instead of pixels, they carry vector data. The map draws the shapes on your device.
Why it is important: Vector tiles are fast and look sharp at any zoom. You can change their style without downloading new tiles.
Simple explanation: Imagine a tile that contains instructions: βDraw a road here, a building there.β Your computer follows the instructions.
Real-life example: MapLibre uses vector tiles to show smooth, rotating maps.
School example: A school map with vector tiles can change colours for different events.
Home example: A weather app uses vector tiles to show rain moving.
Nigerian example: A Lagos traffic app uses vector tiles to show real-time road conditions.
Illustration:
Vector Tile: [π Instructions]
|
V
Your device draws the map
|
V
Sharp at any zoom!
Mini summary: Vector tiles are small packages of vector instructions. They are fast and flexible.
Definition: A layer is one set of data drawn on the map. You can stack many layers.
Why it is important: Layers let you organise information. You can show roads, then rivers, then schools.
Simple explanation: Think of clear plastic sheets. You draw on each sheet. Then you put them on top of each other.
Real-life example: A weather map has a layer for clouds and a layer for temperature.
School example: A geography project might have a layer for rainfall and a layer for rivers.
Home example: A birthday cake has layers of cake and icing.
Nigerian example: A map of Nigeria might have a layer for states and a layer for oil pipelines.
Illustration:
+---------------------+ | Layer 3: Schools | +---------------------+ | Layer 2: Roads | +---------------------+ | Layer 1: Land | +---------------------+
Mini summary: Layers are sheets of data. You can add or remove them.
Definition: You can add more than one layer to your map. They appear in the order you add them.
Why it is important: Most real maps have many layers.
Simple explanation: You create an array (a list) of layers. The first layer is at the bottom.
Real-life example: A map might have a base layer, a roads layer, and a labels layer.
School example: A map of your school might have a layer for buildings and a layer for sports fields.
Home example: A map of your house might have a layer for furniture and a layer for windows.
Nigerian example: A map of Lagos might have a layer for roads and a layer for markets.
Example code:
layers: [
new ol.layer.Tile({ source: new ol.source.OSM() }),
new ol.layer.Vector({ source: myVectorSource })
]
Mini summary: You can add many layers. The order matters.
Definition: MapLibre uses a style file to define layers. The style is a JSON file.
Why it is important: The style tells MapLibre what to draw and how to draw it.
Simple explanation: The style is like a recipe. It lists all the layers and their ingredients.
Real-life example: A MapLibre style might have layers for water, land, roads, and labels.
School example: A school project can use a custom style to show only certain features.
Home example: You can change the style to make a dark map or a light map.
Nigerian example: A Nigerian news website might use a style that highlights major cities.
Illustration:
Style JSON
|
V
+---------------------+
| Layer: Water |
| Layer: Roads |
| Layer: Labels |
+---------------------+
Mini summary: MapLibre layers are defined in a style file. The style controls everything.
Definition: You can show or hide a layer whenever you want.
Why it is important: Sometimes you want to see only roads. Sometimes only schools.
Simple explanation: Each layer has a visibility property. You can set it to true or false.
Real-life example: In a map app, you can tick a box to show traffic.
School example: A teacher can hide the labels layer to test students.
Home example: You can hide the furniture layer to see the walls.
Nigerian example: A map of Nigeria can hide the states layer to show only rivers.
Illustration:
Layer: Roads [β On] Layer: Schools [β Off] Layer: Rivers [β On]
Mini summary: You can turn layers on and off. This is called visibility.
Definition: The order of layers decides what appears on top of what. This is called Z-index.
Why it is important: If a label layer is below a road layer, you cannot see the labels.
Simple explanation: Imagine stacking books. The last book you put on top is the one you see first.
Real-life example: In a map, labels should be on top of everything else.
School example: The title of your drawing should be on top.
Home example: The roof of a house is on top of the walls.
Nigerian example: The label βLagosβ should appear on top of the roads.
Illustration:
Top -> Layer 3: Labels Middle -> Layer 2: Roads Bottom -> Layer 1: Land
Mini summary: Layer order controls what you see on top. Labels usually go on top.
Definition: OGC stands for Open Geospatial Consortium. They make rules for map services. WMS and WFS are two common services.
Why it is important: Many governments and organisations share map data using these services.
Simple explanation: WMS gives you a picture of the map. WFS gives you the actual data (points, lines, shapes).
Real-life example: A weather service might use WMS to show rain maps.
School example: A school can use WFS to get the boundaries of all local government areas.
Home example: You can use WMS to see a flood map of your area.
Nigerian example: The Office of the Surveyor General of Nigeria might provide WFS data for state boundaries.
Table: WMS vs WFS
| Feature | WMS | WFS |
|---|---|---|
| Gives you | A picture (image) | Data (points, lines, shapes) |
| Can you style it? | No, it comes ready-made | Yes, you can style it yourself |
| Best for | Showing maps quickly | Analysing data |
Mini summary: WMS gives pictures. WFS gives data. Both are useful.
Definition: You can add a WMS layer as an image layer in OpenLayers.
Why it is important: Many free WMS services exist. You can use them in your maps.
Simple explanation: You give OpenLayers the WMS URL and the layer name. The picture appears.
Real-life example: You can add a WMS layer showing rainfall over Nigeria.
School example: A geography class can add a WMS layer showing soil types.
Home example: You can add a WMS layer showing flood risk in your area.
Nigerian example: A WMS layer from NiMet could show weather patterns.
Example code:
new ol.layer.Image({
source: new ol.source.ImageWMS({
url: 'https://example.com/wms',
params: { 'LAYERS': 'rainfall' }
})
})
Mini summary: WMS layers are added as image layers. They come ready to show.
Definition: You can combine raster tiles, vector data, and WMS layers in one map.
Why it is important: Real maps use many sources and layers together.
Simple explanation: Start with a base map. Add roads. Add schools. Add a weather layer. Turn some on and off.
Real-life example: A disaster response map might have a base layer, a flood layer, and a layer of hospitals.
School example: A school map might have a base layer, a buildings layer, and a layer of water points.
Home example: A family map might have a base layer, a layer of relativesβ houses, and a layer of markets.
Nigerian example: A map of Abuja might have a base layer, a roads layer, a layer of government buildings, and a layer of bus stops.
Illustration:
+---------------------+ | Weather Layer | +---------------------+ | Schools Layer | +---------------------+ | Roads Layer | +---------------------+ | Base Map (OSM) | +---------------------+
Mini summary: You can combine many layers. Your map becomes rich and useful.
| Word | Simple Definition |
|---|---|
| Data source | Where map data comes from. |
| Raster | Map data made of pixels (like a photo). |
| Vector | Map data made of points, lines, and shapes. |
| GeoJSON | A text file for vector data. |
| Vector tile | A tile that carries vector instructions. |
| Layer | A sheet of data on the map. |
| Visibility | Whether a layer is shown or hidden. |
| Z-index | The order of layers (who is on top). |
| WMS | A service that gives map pictures. |
| WFS | A service that gives map data. |
| OGC | Open Geospatial Consortium β makes map rules. |
new ol.source.Vector({ url: 'data.geojson', format: new ol.format.GeoJSON() }).new ol.layer.Vector({ source: mySource }).var myLayer = new ol.layer.Vector(...).myLayer.setVisible(false).myLayer.setVisible(true).
Start
|
V
Choose a data source
|
V
Create a source object
|
V
Create a layer object
|
V
Add layer to map
|
V
See your data! π
1994 - OGC founded 2004 - OpenStreetMap started 2006 - OpenLayers released 2008 - GeoJSON created 2010 - Vector tiles appear 2020 - MapLibre released 2024 - You learn to use them!
| Source | Type | Best for |
|---|---|---|
| OpenStreetMap | Raster tiles | Base maps |
| GeoJSON file | Vector | Custom data |
| MapLibre demo tiles | Vector tiles | Fast, modern maps |
| WMS service | Raster image | Weather, overlays |
| WFS service | Vector data | Analysis, styling |
| Question | Raster | Vector |
|---|---|---|
| What is it made of? | Pixels | Points, lines, polygons |
| Can you zoom without blur? | No | Yes |
| Can you change colours? | Hard | Easy |
| File size | Large | Small |
| Example | Satellite photo | Road network |
Lesson 1: A data source is where map data comes from.
Lesson 2: Raster data is made of pixels, like a photo.
Lesson 3: Vector data is made of points, lines, and shapes.
Lesson 4: Raster is pixels. Vector is shapes. Both are useful.
Lesson 5: OpenStreetMap is a free tile source.
Lesson 6: GeoJSON is a text file for vector data.
Lesson 7: Vector tiles carry instructions, not pictures.
Lesson 8: Layers are sheets of data you can stack.
Lesson 9: You can add many layers in OpenLayers.
Lesson 10: MapLibre uses a style file to define layers.
Lesson 11: You can turn layers on and off.
Lesson 12: Layer order controls what you see on top.
Lesson 13: WMS gives pictures. WFS gives data.
Lesson 14: You can add a WMS layer in OpenLayers.
Lesson 15: You can combine many layers for a rich map.
In this module, you learned how to add information to your maps using data sources and layers. You discovered the difference between raster and vector data. You learned how to load tiles from OpenStreetMap, how to use GeoJSON files for vector data, and how vector tiles work in MapLibre. You also learned how to stack layers, turn them on and off, and control their order. You explored OGC services like WMS and WFS. Finally, you saw how to combine everything into a rich, useful map. You are now ready to go deeper into styling and interaction.
Match the word to its meaning.
| Word | Meaning |
|---|---|
| 1. Raster | A. Made of points, lines, and shapes |
| 2. Vector | B. Where map data comes from |
| 3. Source | C. Made of pixels |
| 4. Layer | D. A sheet of data on the map |
| 5. WMS | E. Gives map pictures |
Answers: 1-C, 2-A, 3-B, 4-D, 5-E
Title: Build a Layered Map of Your School
Instructions: In groups of 3, draw a map of your school on paper. Use different coloured sheets for different layers: one for buildings, one for sports fields, one for water points. Stack them. Discuss how you would turn each layer on and off. Present to the class.
Title: My First GeoJSON File
Instructions: Create a GeoJSON file with three points: your home, your school, and your favourite shop. Use longitude and latitude. Then load it into an OpenLayers map. Write down what you see.
Title: A Map of My Favourite Places with Layers
Instructions: Create an HTML file with a MapLibre or OpenLayers map. Add a base layer. Add a vector layer with at least three markers (home, school, shop). Add popups for each marker. Add a button or checkbox to turn the markers on and off. Save and show your family.
Task: Write a short paragraph (5 sentences) explaining what you learned about data sources and layers. Then, list three things you found easy and one thing you found hard.
In Module Three, we will learn about style configuration and data-driven visualization. We will make our maps beautiful and informative. We will change colours, sizes, and shapes based on data. To get ready, make sure you:
See you in Module Three! π
End of Module Two Β· Certified OpenLayers/MapLibre User