How a web map is built

Every map visual, whether it's a web app, a Python notebook, a Power BI report or a saved image, goes through the same chain: choose what to show, get the data, project it, tile it, serve it, style it, draw it and publish it. This guide walks the chain in that order. Each chapter tells you the decision you make at that step and the tools that do it.

Tools you asked about

  1. Decide what to showmap types, basemap vs data
  2. Get the dataformats, sources, coordinates
  3. Project itWeb Mercator
  4. Tile it, or notpyramid, raster vs vector
  5. Serve the tileshosting, keys, limits
  6. Style itlayers, colour, order
  7. Render itpick a library, go 3D
  8. Add interactionpopups, search, routing
  9. Publishchecklist
  10. Recipescode to start from
Chapter 1

Decide what the map must show

Almost every map visual has two parts. The basemap gives context: land, water, roads, labels. Usually you borrow it from a provider. The data layer carries your message: your stores, your sales by region, your delivery routes. Most of your effort goes into the data layer, and its form depends on the question you're answering.

City positions are real. Values and flows are illustrative.

Map type

Use it for
Data you need
Watch out for
Chapter 2

Get the data into a geographic format

Map data is either vector (points, lines and polygons, such as stores, roads and suburb boundaries) or raster (a grid of pixels, such as satellite imagery or elevation). Positions are stored as longitude and latitude on the WGS 84 system, code EPSG:4326. That's what a GPS gives you.

FormatWhat it isUse it when
CSV with lat/lon columnsA plain table with two coordinate columnsYou only have points. It's the easiest way into Power BI, Plotly or Folium.
GeoJSONText file of features and properties, the web standard. Coordinates are always [longitude, latitude].Points, lines or polygons up to a few MB. Every web library reads it directly.
ShapefileAn older GIS format split across several files (.shp, .dbf, .shx, .prj)Government boundary downloads often come this way. Convert it to GeoJSON or GeoPackage.
GeoPackageA modern single-file GIS databaseYou work in QGIS or GeoPandas and want one tidy file.
GeoParquetA columnar format for large datasetsMillions of features, or analysis in Python or a data warehouse. Overture publishes in it.
GeoTIFFA raster image with location attachedImagery, elevation, land cover.

Where the data comes from

OpenStreetMapCrowdsourced roads, buildings and places. Free, and you must credit "OpenStreetMap" with a link to its copyright page.
Overture MapsOpen map data from Amazon, Meta, Microsoft and TomTom
Natural EarthFree low-detail world data: countries, coastlines, rivers
Official boundariesStatistical areas from a national statistics office. In Australia that's the ABS (see the ASGS explainer).
Your own dataSpreadsheets of addresses, sales, assets

Preparing it

Addresses into coordinates: run them through a geocoder such as Nominatim, Photon or a paid API, then keep the lat/lon so you don't geocode again. Public Nominatim allows one request per second, so batch jobs need your own instance or a paid service.

Values onto regions: join your table to boundary polygons with a shared code (a postcode or region ID), not a name. Names are ambiguous.

Shrink big boundaries: simplify polygons with mapshaper or GeoPandas before using them on the web. Detailed coastlines can be tens of MB.

Shapes crossing the 180° line: GeoJSON expects them split in two (common around Fiji, Russia and Alaska). Unsplit shapes draw as a band across the whole map.

Tools: QGIS (free desktop GIS), GeoPandas (Python), GDAL's ogr2ogr (converts anything to anything).

The most common mapping bug

Libraries disagree on coordinate order. GeoJSON, MapLibre, deck.gl and Plotly use [longitude, latitude]. Leaflet and Folium use [latitude, longitude].

[-74.01, 40.71]

New York, read correctly.

Chapter 3

Project it onto a flat screen

The Earth is round and screens are flat, so every map uses a projection. Web maps use Web Mercator (EPSG:3857). It draws the world as a square, keeps shapes and angles true and stretches sizes toward the poles. It stops at about 85° north and south.

1.0×

At the equator a 1,000 km square is drawn at its true size.

Greenland sits near 72°N, so it's drawn about 10 times too large in area. That's why it rivals Africa on screen, although Africa is about 14 times bigger. Across Greenland's own latitudes the stretch runs from about 4× in the south to over 60× in the far north.

Usually you don't project anything

Keep your data in latitude/longitude. MapLibre, Leaflet, Plotly and Power BI convert it to Web Mercator as they draw.

Static maps need you to do it

To draw over web tiles in Python, convert first: gdf.to_crs(epsg=3857). Otherwise your data and the basemap won't line up.

Compare areas? Change projection

A world choropleth in Mercator exaggerates high-latitude countries. For printed thematic maps, an equal-area projection such as Equal Earth is fairer. MapLibre GL JS 5 (January 2025) can also draw the map as a globe, which avoids the stretch when zoomed out. Look up any code at epsg.io.

Chapter 4

Cut it into tiles, or skip this step

A basemap of the whole world is far too big to download, so it's cut into a pyramid of tiles. Zoom 0 is one tile showing the world, and each level splits every tile into four. Your map fetches only the tiles on screen. Turn the pyramid, hover a tile for its address, and click one to see its children.

Drag to rotate. Hover a tile for its address. Click a tile to see its four children.

Loading coastlines…

Tile address

z / x / y
Request
/tiles/z/x/y.png
West–east
–
South–north
–

x counts from the left and y from the top, as in Google, OpenStreetMap and OGC WMTS. The older TMS scheme counts y from the bottom.

How fast it grows

Tiles at this level
1
World width
256 px
Ground per pixel
156.5 km
Scale at 96 dpi
1 : 591,658,711

256 px tiles, measured at the equator. Many services now use 512 px tiles, which shifts the figures by one level. Published scales also differ with the assumed pixel size: OGC's standard uses 0.28 mm pixels and gets 1 : 559,082,264 at zoom 0.

Each level keeps its own detail

When tiles are built, each zoom level gets only what suits its scale. The top shows land and sea, and lower levels add borders, roads and buildings. Notice the borders appear from z2 above.

Built once, fetched often

The pyramid is generated in advance and stored. Some servers, such as Martin, can also build tiles from a database when they're requested.

Two kinds of tile

Raster tiles are pictures (PNG, JPEG, WebP) with the style baked in. Vector tiles (the Mapbox Vector Tile format, .mvt, often also served as .pbf) carry shapes and attributes, and get coloured later. Try both below.

Raster tiles are pictures, vector tiles are data

Both tiles cover the same square, z2 x2 y1. Restyle them.

Raster tile 2/2/1 with a fixed style
Raster · /2/2/1.png · the style is part of the image
Vector · /2/2/1.mvt · coloured by the chosen style

Do you need to make tiles?

For the basemap: no. Use a provider's tiles: OpenStreetMap, MapTiler, CARTO, or a Protomaps build.

For your own data: usually not. A GeoJSON file of up to a few MB, or a few tens of thousands of features, can be loaded straight into the map.

Only for large data, such as every building in a country or millions of points, cut your own vector tiles.

Tile tools and files

TippecanoeTurns GeoJSON, FlatGeobuf or CSV into vector tiles, decides what to keep at each zoom, and can write PMTiles directly. Now maintained by Felt.
PMTilesA whole pyramid in one file, readable from plain cloud storage (from Protomaps)
MBTilesA pyramid stored in one SQLite file, served by a tile server. Rows are stored in TMS order, so y is flipped.
MartinTile server for PostGIS (built on request), MBTiles, PMTiles, Cloud-Optimised GeoTIFF and GeoJSON
MapTilerBuilds tiles from your data (MapTiler Engine) and hosts them
Chapter 5

Serve the tiles

Your map holds almost no data of its own. It asks a tile service, a server that hands out tiles by address, for each square it needs. Move the map and watch the requests, then change the server's rules.

Requests appear when this section comes into view.
Requests 0Answered 0Refused 0
Where tiles come fromHow it worksWatch for
A free public serverFor example tile.openstreetmap.org. No key needed.No uptime guarantee, and access can be withdrawn at any time. You must show attribution, send a real User-Agent and Referer, and cache tiles for at least 7 days. Bulk or offline downloading is banned. Fine for a demo, not for a product.
A hosted providerMapTiler, CARTO, Mapbox, Stadia and others. You get an API key.Free tiers have monthly limits, after which you pay per map load or per tile. Restrict the key to your domain.
Your own server or storageHost a PMTiles file on cloud storage, or run a tile server.No outside limits. You handle updates, uptime and bandwidth.

The tile service is a live dependency, not a one-time download. If it's slow, refuses you or goes down, your map breaks, even when your own code is fine. A 403 means you're not allowed (missing key, wrong domain). A 429 means you've sent too many requests.

Chapter 6

Style it

With vector tiles, a Style JSON decides how everything looks. It's a list of layers drawn in order, bottom to top: water, land, roads, your data, then labels. Each layer picks features from a source, filters them, and sets colours, widths, fonts and the zoom range where it appears. With raster tiles this step already happened on the server.

// one layer from a Style JSON: your sales regions, coloured by value
{
  "id": "sales-regions",
  "type": "fill",
  "source": "regions",
  "minzoom": 4,
  "paint": {
    "fill-color": ["interpolate", ["linear"], ["get", "sales_per_head"],
      0, "#e6f2f0",
      500, "#0f857a"],
    "fill-opacity": 0.8
  }
}

The colour comes from each feature's own value. This is called data-driven styling.

Rules that make thematic maps readable

Put your data under the labels. Insert your layer below the first label layer so place names stay readable.

Pick the colour scale for the data. Use a sequential scale (light to dark) for amounts. Use diverging (two colours from a midpoint) for above/below a target, and categorical (distinct hues) for types. Avoid rainbow scales.

Map rates, not counts, on regions. Big regions have big totals. Divide by population or area first.

Mute the basemap. A light or grey basemap lets your data stand out.

Tools: Maputnik (free visual Style JSON editor), MapTiler's style editor, or a ready-made style from your tile provider.

Chapter 7

Render it: pick the library

The renderer draws tiles, style and your data on screen. Your choice decides which kind of tile you can use, and that changes where the styling step happens. Pick one and watch the steps re-order.

Web Python BI tools

Data

Your points, lines or regions in latitude/longitude.

Tiles

Style

Render

LibraryCoordinate orderDraws withBest for
MapLibre GL JS[lon, lat]WebGLCustom-styled vector maps, large datasets, 3D, no vendor lock-in
Leaflet[lat, lon]SVG or CanvasSimple maps with markers and popups, quick to learn, many plugins
OpenLayers[lon, lat], projectedCanvas or WebGLGIS-heavy apps with many projections and formats
deck.gl[lon, lat]WebGLHundreds of thousands of points, arcs, hexbins, 3D columns
Folium (Python)[lat, lon]LeafletQuick interactive maps from a notebook, saved as HTML
Plotly (Python)lat=, lon= columnsMapLibreMaps inside Plotly dashboards, scatter and choropleth
GeoPandas + contextilyCRS-awareMatplotlibStatic images for reports and print
Power BI, TableauLatitude / Longitude fieldsBuilt-in visualsMaps in business dashboards, filtered with the rest of the report

Lots of points? SVG-based Leaflet slows down past a few thousand markers. Use clustering, switch to its Canvas renderer, or move to a WebGL library such as MapLibre or deck.gl, which handle hundreds of thousands.

Going 3D: extruded blocks or photorealistic cities

"3D buildings" means two different things, built from different data with different tools.

Extruded buildings

Building footprints raised to their height as plain blocks you can colour by any value. The heights come from OpenStreetMap's height and building:levels tags, or from Overture.

Tools: MapLibre or Mapbox (a fill-extrusion layer in the Style JSON), deck.gl, Plotly. It's cheap and fully styleable. It works anywhere building data exists, but it looks like a model, not a photo.

Terrain: the same style spec has hillshade and color-relief layers that shade hills and colour by height from an elevation source.

Photorealistic 3D

A textured mesh of real buildings, trees and terrain, captured from aerial imagery. Google's Photorealistic 3D Tiles cover thousands of cities (Google quotes 2,500+ in 49 countries) and are delivered in the open OGC 3D Tiles format, a 3D version of the tile pyramid.

Tools: CesiumJS, deck.gl's Tile3DLayer, or Google's own 3D Maps in the Maps JavaScript API. You need a Google Maps Platform key with the Map Tiles API enabled. Billing is per root tileset request, and each request opens a session of up to 3 hours. You must show the tiles' attributions on one line plus the Google Maps logo, and you can't cache them beyond Google's terms or use them offline. Coverage is mainly large cities.

// CesiumJS: Google's photorealistic city mesh on a page
// (load Cesium's JS and CSS, and add <div id="viewer"></div>)
Cesium.GoogleMaps.defaultApiKey = 'YOUR_GOOGLE_MAPS_KEY';
const viewer = new Cesium.Viewer('viewer', { globe: false });   // the tiles include their own terrain
viewer.scene.primitives.add(await Cesium.createGooglePhotorealistic3DTileset());
viewer.camera.flyTo({ destination: Cesium.Cartesian3.fromDegrees(151.2093, -33.8688, 900) });  // lon, lat, height in m

Just want to look, without building anything? Google Earth on the web and the 3D view in Google Maps or Apple Maps use the same kind of data.

Chapter 8

Add interaction and services

A map visual is only useful if people can read it and ask it questions. Add these to the data layer, and add search or routing as separate services.

Popups and tooltips

Show the value behind a point or region on hover or click. Keep it to the two or three fields that answer the question.

Legend and title

A thematic map without a legend can't be read. State what the colour or size means, the units and the date of the data.

Zoom to the data

Open the map fitted to your features (fitBounds), not the whole world. Add clustering when points overlap.

Search (geocoding)

A search box turns typed addresses into positions. Photon gives fast autocomplete. Nominatim is OpenStreetMap's own, but its public server forbids autocomplete. Pelias is another open option.

Routing

Directions, travel time and distance. OSRM, Valhalla and GraphHopper run on OpenStreetMap data, self-hosted or through a provider.

Filters and time

Let people narrow by category or date. In BI tools this comes free through slicers. On the web, filter the layer rather than reloading data.

Chapter 9

Publish

Before the map goes in front of people, check these.

Recipes

Five ways to start

Each recipe maps the same file, stores.geojson, a set of points with a name property, centred on Sydney. Pick the one that matches where your map will live.

Leaflet + OpenStreetMap raster tiles

You handle: data and render. Tiles, style and serving come from OpenStreetMap. Fine for prototypes. Switch to a provider for real traffic. Written for Leaflet 1.9, the stable release. Leaflet 2 (in alpha) replaces calls like L.marker() with classes like new Marker().

<!-- in the page: Leaflet's CSS and JS from unpkg, and <div id="map" style="height:500px"></div> -->
const map = L.map('map').setView([-33.87, 151.21], 11);   // [lat, lon]

L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
  maxZoom: 19,
  attribution: '<a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);

fetch('stores.geojson').then(r => r.json()).then(data => {
  const layer = L.geoJSON(data)
    .bindPopup(l => l.feature.properties.name)
    .addTo(map);
  map.fitBounds(layer.getBounds());
});
Shortcuts

Platforms that do several steps for you

These bundle data, tiles, styling and hosting into one product. You trade money and flexibility for speed.

CARTOSpatial analysis and maps on top of your data warehouse (BigQuery, Snowflake and others). Also offers free basemaps.
MapTilerTurns your files into tiles, hosts them, and provides basemap styles and an editor.
MapboxFull developer stack: tiles, styles, Studio editor, search and routing. MapLibre is the open-source fork of its earlier engine.
Google Maps PlatformEasiest to drop in, with strong places and Street View, but limited styling. Priced per request.
Esri ArcGISEnterprise GIS covering analysis, data management and publishing. Deep and expensive.
Summary

The chain in one breath

  1. Start from the question. Choose points, sized circles, filled regions, a heatmap or lines, on a muted basemap.
  2. Get the data in latitude/longitude. Use GeoJSON or CSV for small sets and join regions by code. Mind [lon, lat] vs [lat, lon].
  3. Web maps use Web Mercator. Libraries project for you. Static maps and area comparisons need care.
  4. Basemaps come as a tile pyramid. Borrow one. Only tile your own data when it's large.
  5. Raster or vector decides where style happens. Raster is styled on the server. Vector is styled in your app with a Style JSON.
  6. The tile service is a live dependency. Keys, limits and attribution decide whether your map keeps loading.
  7. The renderer sets your options. Leaflet and Folium for simple raster maps, MapLibre for styled vector maps, deck.gl for big data, BI visuals for dashboards.