Module 00 - How the Web Draws a Map

Level 0 ยท Foundations ยท ๐ŸŸข Beginner ยท 2 hours ยท No prerequisites


What you'll build

Nothing yet - this is the one module with no code you keep. Instead you will take apart three live maps in DevTools and be able to explain, precisely, what happened between your click and the pixels on screen.

By the end you will be able to look at a network waterfall on any web map in the world and say what kind of map it is.


Why this matters

Almost every hard bug in web GIS is a bug about where work happens: on the server, in a tile, in the browser, or on the GPU. If you don't have that model, you will write code that downloads two million features to draw a dot, or that asks the server for the same tile 400 times, and you won't know why it's slow.

Fifteen minutes of theory here saves you a week in Level 5.


Concepts

1. A map is too big to send

The world at street-level detail is petabytes. You cannot send it. Every web mapping system is some answer to the question: what subset do we send, and when?

There are exactly three answers, and every map you have ever used is one of them or a mix.

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  ANSWER 1: Send pictures.            (raster tiles)            โ”‚
โ”‚  Server pre-renders the whole world into images at every zoom. โ”‚
โ”‚  Browser downloads the 20-ish images covering the screen.      โ”‚
โ”‚  โ†’ Fast, dumb. Can't restyle, can't click a feature.           โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  ANSWER 2: Send compressed geometry. (vector tiles)            โ”‚
โ”‚  Same tile grid, but each tile holds geometry + attributes.    โ”‚
โ”‚  Browser styles them at draw time on the GPU.                  โ”‚
โ”‚  โ†’ Restyleable, rotatable, crisp at any DPI. More CPU.         โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  ANSWER 3: Send the actual features. (feature services)        โ”‚
โ”‚  Browser asks: "give me features where TYPE='school' in this   โ”‚
โ”‚  extent." Server returns real geometry + attributes as JSON.   โ”‚
โ”‚  โ†’ Queryable, editable, analysable. Doesn't scale to millions. โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Your basemap is almost always 1 or 2. Your data is almost always 3.

That single sentence is the architecture of every application in this course.

2. The tile grid

Tiles solve "what subset" with a fixed pyramid. Level 0 is one tile covering the world. Level 1 splits it into 4. Level 2 into 16. Each level quadruples the count.

z=0            z=1                 z=2
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”         โ”Œโ”€โ”ฌโ”€โ”ฌโ”€โ”ฌโ”€โ”
โ”‚       โ”‚     โ”‚0,0โ”‚1,0โ”‚         โ”œโ”€โ”ผโ”€โ”ผโ”€โ”ผโ”€โ”ค
โ”‚  0,0  โ”‚     โ”œโ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”ค         โ”œโ”€โ”ผโ”€โ”ผโ”€โ”ผโ”€โ”ค
โ”‚       โ”‚     โ”‚0,1โ”‚1,1โ”‚         โ”œโ”€โ”ผโ”€โ”ผโ”€โ”ผโ”€โ”ค
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”˜         โ””โ”€โ”ดโ”€โ”ดโ”€โ”ดโ”€โ”˜
 1 tile        4 tiles           16 tiles

A tile is addressed by three numbers: z (zoom), x (column), y (row). A tile URL looks like:

https://tile-server/tiles/14/4823/6160.png
                          z    x     y

At zoom 14, there are 2ยนโด = 16,384 columns and rows - 268 million tiles for the whole world. Nobody renders all of them; servers render on demand and cache.

Why 256ร—256? Historical, and a good fit for texture memory. Many modern services use 512ร—512 to halve the request count on high-DPI screens.

What determines how many tiles you download? Your viewport size รท tile size, plus a margin. A 1920ร—1080 screen at 256px tiles needs about (1920/256 + 1) ร— (1080/256 + 1) โ‰ˆ 8 ร— 5 = 40 tiles. That is why panning feels smooth and zooming feels chunky - zooming invalidates all 40 at once.

3. Zoom, scale and resolution

These three describe the same thing and you will see all three in the API.

Term What it is Example
Zoom level Integer tile pyramid level 13
Scale Map units per screen unit, as a ratio 1:36,112
Resolution Ground metres per pixel 9.55 m/px

The relationship in Web Mercator:

resolution(z) = 156543.03392 / 2^z      metres per pixel at the equator
scale(z)      = resolution(z) ร— 96 / 0.0254   (96 dpi assumed)

Some quick anchors worth memorising:

Zoom Resolution You can see
0 156 km/px The whole world
5 4.9 km/px A country
10 153 m/px A city
15 4.8 m/px A neighbourhood, individual buildings
18 0.6 m/px Cars, road markings
20 0.15 m/px Beyond most imagery's actual resolution

In the SDK you will set view.zoom (2D) or view.scale, and read view.resolution. SceneView has no zoom in the same sense - it has a camera at an altitude (Module 28).

4. Raster tiles vs vector tiles

This is the single most useful distinction for reading a network tab.

Raster tile Vector tile
Payload PNG / JPEG / WebP image Protobuf (.pbf) with geometry + attributes
Typical size 20-150 KB 5-80 KB
Styling Baked in at render time on the server Applied in the browser from a style JSON
Rotation Labels rotate too (ugly) Labels stay upright
High DPI Needs @2x tiles, doubles bytes Free - it's geometry
Restyle to dark mode New tile set Swap the style JSON
Click a road to get its name Impossible Possible
CPU cost Near zero Real - parse + tessellate + draw

The ArcGIS basemap styles service (arcgis/navigation, arcgis/dark-gray, โ€ฆ) serves vector tiles. Satellite imagery is necessarily raster.

Why can vector tiles restyle to dark mode for free? Because the tile contains { geometry: [...], layer: "road", class: "motorway" } and the style says road/motorway โ†’ #444 with a #666 casing. Change the style, redraw the same tile. A raster tile already has #fff roads burned into its pixels.

5. Where the drawing actually happens: WebGL

Both view types render through WebGL - the browser's binding to the GPU.

The pipeline, simplified:

Feature JSON / vector tile
        โ”‚
        โ–ผ
   TESSELLATION       polygons โ†’ triangles, lines โ†’ quads
        โ”‚             (this is CPU work, often in a Web Worker)
        โ–ผ
   VERTEX BUFFERS     arrays of positions + colours uploaded to GPU memory
        โ”‚
        โ–ผ
   DRAW CALLS         "GPU, draw these 40,000 triangles with this shader"
        โ”‚
        โ–ผ
   FRAGMENT SHADER    per-pixel colour
        โ”‚
        โ–ผ
   FRAMEBUFFER โ†’ your screen, 60 times a second

Two performance facts fall out of this diagram, and they explain most "my map is slow" tickets:

  1. Draw calls are expensive; triangles are cheap. 50,000 points that share one symbol batch into a handful of draw calls and render at 60 fps. 500 polygons each with a unique symbol may not batch at all. This is why "fewer features" is not always the fix.
  2. Tessellation is CPU work on the main thread unless the SDK moves it to a worker. A complex polygon with 100,000 vertices will jank your UI while it is being triangulated, even though the GPU draws it instantly. Simplify geometry (Module 25) before you blame WebGL.

6. The request path, end to end

Here is what happens when you pan a map with a basemap and one feature layer:

 1. User drags.
 2. View computes the new extent.
 3. Basemap: which z/x/y tiles cover the new extent and aren't cached?
    โ†’ 6 HTTP GETs to basemaps-api.arcgis.com
 4. FeatureLayer: the LayerView computes which features it needs.
    โ†’ POST to .../FeatureServer/0/query
       { geometry: <new extent>, spatialRel: "esriSpatialRelIntersects",
         outFields: ["*"], returnGeometry: true, f: "json" }
 5. Server runs a spatial index lookup, returns matching features as JSON.
 6. Browser parses JSON โ†’ tessellates geometry โ†’ uploads to GPU.
 7. Next animation frame draws basemap tiles, then feature triangles, then labels.

Step 4 is where your money goes. Every module in Level 5 is really about making step 4 smaller.

7. Client, server, and the line between them

Job Where it can happen Trade-off
Filter by attribute Server (definitionExpression) or client (FeatureFilter) Server = less data, a round trip. Client = instant, needs data already loaded
Compute a sum Server (outStatistics) or client (loop) Server always wins for large N
Buffer a geometry Client (geometry operators) or server (GP service) Client for interactive, server for heavy/authoritative
Symbolise Client (renderer) or server (map service image) Client, always, in this SDK
Label placement Client Deconfliction needs to know your screen
Geocode an address Server, always It's a database you don't have

Learn to ask "where is this happening?" about every operation. That question is the whole skill of this level.


Build it - take apart three real maps

No code. DevTools only. Do all three; each teaches a different thing.

Step 1 - A raster basemap

  1. Open https://www.arcgis.com/apps/mapviewer/index.html
  2. Open DevTools โ†’ Network โ†’ filter to Img
  3. Change the basemap to Imagery
  4. Pan and zoom

Observe and write down:

  • The tile URL pattern. Find the z/x/y in it.
  • The size of one tile in KB
  • How many tiles load when you pan by half a screen
  • What happens to already-loaded tiles when you pan back (hint: check the Size column for (memory cache) / (disk cache))

Then answer: if a user pans across a city for two minutes, roughly how many MB do they download? Multiply by 1,000 daily users. That is why tile caching is a business concern.

Step 2 - A vector basemap

  1. Same map, switch the basemap to Navigation or Topographic
  2. Network โ†’ filter to Other or search .pbf
  3. Pan and zoom

Observe:

  • Tile payloads are now .pbf, and smaller
  • There is a one-time request for a style JSON (search resources/styles) - open it and look at the layers array. This is the entire cartography of the basemap as data.
  • Rotate the map (right-drag). The labels stay horizontal. A raster basemap cannot do that.

Then answer: find the style rule for water. What colour is it? Change it in your head to #000 - what would the map look like? You have just understood how dark-mode basemaps work.

Step 3 - A feature service

  1. Open this URL directly in a browser tab:
    https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/USA_Major_Cities/FeatureServer/0
    
  2. Read the HTML page the server returns. This is the ArcGIS REST API - a self-describing endpoint. Note: geometryType, fields, maxRecordCount, capabilities.
  3. Now query it. Append this to the URL:
    /query?where=POPULATION>500000&outFields=NAME,POPULATION&returnGeometry=false&f=json
    
  4. Read the JSON.

Observe:

  • where is SQL. The server is running a database query.
  • f=json chose the format. Try f=geojson and f=html.
  • maxRecordCount (usually 1000 or 2000) caps how many features come back per request. This number will bite you in Module 23.

Then answer: how would you get the count of matching cities without downloading them? (Try returnCountOnly=true.) You have just done server-side aggregation, which is Module 26.


How it works

Why the tile grid is square when the Earth is not

Web Mercator (EPSG:3857) projects the globe onto a square by stretching latitude toward the poles. It has to truncate at ยฑ85.051129ยฐ or the square would be infinitely tall. That is why you cannot pan to the North Pole on most web maps.

The projection is conformal: angles and local shapes are preserved, which is why streets meet at the right angles and buildings look like buildings. The cost is area: Greenland renders about 14ร— too large.

The consequence you will hit in code: Web Mercator coordinates are in "metres" but they are metres at the equator. At latitude ฯ†:

ground_metres = projected_metres ร— cos(ฯ†)

At 44ยฐ N (Kingston, Ontario) that is a 28% error. Module 25 covers the fix. This repo hit exactly this bug - see CLAUDE.md, gotcha #6.

Why feature services paginate

A feature service is a database with a spatial index (usually R-tree or a quadkey scheme). When you send an extent, it does an index lookup and streams matching rows. Without maxRecordCount, one careless where=1=1 on a 50-million-row layer would try to serialise 50 million geometries into JSON.

So the server caps it. Your client then has three options, which map directly to three modules:

  • Ask for fewer features (filtering, Module 21)
  • Ask for less per feature (outFields, returnGeometry: false, Module 23)
  • Ask the server to summarise instead of returning rows (outStatistics, Module 26)

Why the SDK has both a Map and a MapView

Because the data model and its rendering are genuinely separate concerns, and separating them buys you real things:

  • The same Map can be shown in a 2D MapView and a 3D SceneView simultaneously (a common "compare" UI)
  • A Layer is loaded once, but has one LayerView per view - so you can filter it in one view and not the other
  • Saving a WebMap saves the Map, not the camera

Every framework has an equivalent split. React has elements vs. DOM nodes. This is that.


Common mistakes

"I'll just load all the features and filter in JavaScript." Works at 1,000 features. Falls over at 100,000. Learn the server-side path first (Module 21) and reach for client-side only when you've measured that the data fits.

Confusing zoom level with detail level of your data. Zoom controls the basemap pyramid. Your feature layer will happily draw a 5-metre-accurate parcel boundary at zoom 3, where it is one-tenth of a pixel wide - and pay full tessellation cost to do it. Use minScale/maxScale on layers (Module 08).

Assuming a tile request that 404s is broken. Tile servers legitimately 404 tiles over ocean or outside the data extent. Look for a pattern of 404s, not individual ones.

Reading layer.fields immediately after new FeatureLayer(). It is null. The service hasn't answered yet. This is the async wall from the Instructor Guide, and it starts here.


Exercises

Exercise 00.1 - Tile arithmetic

Without code:

  1. How many tiles exist at zoom 12 for the whole world?
  2. At zoom 16, roughly how many ground metres does one 256px tile cover at the equator?
  3. Your app shows a 1600ร—900 viewport. Roughly how many tiles per screen at 256px? At 512px?
  4. If each tile is 40 KB, what is the payload for one screenful at 256px?
  1. 2^12 ร— 2^12 = 4096 ร— 4096 = 16,777,216
  2. resolution(16) = 156543.03 / 65536 โ‰ˆ 2.39 m/px. ร— 256 px = ~611 m per tile edge.
  3. 256px: โŒˆ1600/256โŒ‰+1 ร— โŒˆ900/256โŒ‰+1 = 8 ร— 5 = 40. 512px: 5 ร— 3 = 15.
  4. 40 ร— 40 KB = 1.6 MB per screen. Now imagine a user panning for 5 minutes.

Exercise 00.2 - Classify five maps

Open five map sites you use (Google Maps, OpenStreetMap, your city's open data portal, a weather site, a real estate site). For each, use DevTools to determine:

  • Raster or vector basemap?
  • Is the data drawn as tiles or as features?
  • Roughly how much data does one screenful cost?

Write two sentences per site. This is the single most transferable skill in this module.

Exercise 00.3 - Break the maxRecordCount

Using only the browser URL bar and the USA_Major_Cities service:

  1. Get all cities in one state, as JSON
  2. Get only their names, without geometry
  3. Get the count of cities with population over 100,000
  4. Get the sum of population across all of them (hint: read the REST docs for outStatistics)

You will use all four of these in Level 5. Doing them by hand first makes the API make sense.


Checkpoint

  1. Name the three strategies for getting map data into a browser, and what each is good at.
  2. A tile URL ends in /14/4823/6160.png. What is 14? What is 4823?
  3. Why can a vector basemap be restyled to dark mode but a raster one cannot?
  4. You have 200,000 points to draw. What makes this fast or slow - the number of points, or something else?
  5. Why is a distance computed from raw Web Mercator coordinates wrong, and by how much at 60ยฐ N?
  1. Raster tiles (pre-rendered images - fast, not queryable), vector tiles (geometry+attributes, styled client-side - restyleable, rotatable), feature services (real features on demand - queryable, editable, analysable but doesn't scale to millions on screen).
  2. 14 is the zoom level; 4823 is the tile column (x). 6160 is the row (y).
  3. The vector tile carries geometry plus a class/layer tag, and colour is applied at draw time from a separate style document. The raster tile's colours are already pixels.
  4. Mostly not the point count. It's draw-call batching (do they share a symbol?), geometry complexity, attribute payload size, and label deconfliction. 200k identical dots is fine.
  5. Because Web Mercator metres scale by 1/cos(latitude). At 60ยฐ N, cos(60ยฐ) = 0.5, so projected distances are 2ร— too large.

Further reading


Next: Module 01 - The JavaScript You Actually Need