How to design a live map of points (frontend)
The first sections are free. The deep dives, level expectations and quiz are part of Pro.
On this page
- The problem
- Clarifying questions
- The requirements menu
- Non-functional requirements
- Estimates
- Core entities
- The API
- The high-level design
- What breaks first
- The deep dives
- Entity fields
- Far more points than the page can hold
- New sign-ups arriving live
- Panning and zooming
- Variants
- What each level is expected to show
- The 30-second answer
- Quiz
The problem
A world map on an internal dashboard where each new sign-up is a point, new ones land while someone looks, and the view goes from the whole globe to one street. The design turns on one gap: there are about a hundred times more points than a page can draw, so zoom has to be part of each request. The server answers with grouped counts when the view is wide and with raw points when it is narrow, a single canvas draws whatever comes back, and new sign-ups are folded into that picture in batches rather than one redraw at a time. One candidate's report on FrontendLead of a LinkedIn onsite describes this map as the design round and says they could not tell what was being judged. Our advice: lead with the gap between the data and the screen, then the live path, and put a number on each.
Clarifying questions
| Ask | Why it matters | A typical answer |
|---|---|---|
How many sign-ups are there in all, and how fast do new ones arrive on a normal day and in a burst? | The first number decides whether the browser can ever hold the data; the second decides how the live path has to be built. A map of a few thousand points is a different question from one of a hundred million. | Say 100,000,000 points in all. No burst rate is given: assume a campaign can bring far more in a minute than a normal day does, and design the live path so that a burst changes batch sizes rather than redraw frequency, with a buffer cap and a refetch as the fallback when it is exceeded. |
When the view is wide, do people need exact counts, or is a heat map enough? | Clusters with counts can be clicked and read; a heat map is calmer but has no discrete groups to click without extra hit-testing. The choice changes what the server returns and what the canvas draws. | Clicking a group to see what is inside is a requirement, so clusters with counts are the default. A heat map is a fair alternative to mention for the widest zooms. |
Is the base map (the streets and coastlines) ours to build, or do we use a map library? | Building a base map is a separate, large problem. Using a library means our work is the data layer on top of it and the requests behind it. | Use a library. Drawing the base map is out of scope; you own the layer of points and clusters, the requests, the cache and the live connection. |
Which devices and browsers? Is this desktop dashboards or phones too? | Memory and GPU budgets differ a lot between a desktop dashboard and a phone, which changes how much the client may keep in memory and how large an answer may be. | Internal dashboards, mostly desktop, but the targets stay the same: 60 frames a second while moving and a response within 200 milliseconds. |
What does live mean here: each sign-up within a second or two, or a refresh every so often? | Within seconds calls for an open connection and batching; a refresh every few minutes could be a timer and a button. | Within a few seconds. Batching several sign-ups into one update is fine; making someone press refresh is not. |
What shows on a click, and does anyone have restricted access to some sign-ups? | A click on a point needs a details call; clicking a cluster needs a plan for thousands of members. Access rules would change what the server returns. | A click on a point fetches |
Non-functional requirements
| Requirement | What it forces |
|---|---|
Panning and zooming stay at 60 frames a second | Main-thread work during a move has to fit the frame budget, which in this design means parsing and grouping move to a worker and there is no per-point DOM work. Points live in typed arrays on a canvas or WebGL layer, and movement redraws what is already there instead of waiting for the network. |
The page never loads the whole data set, only what the view needs | Bounds and zoom go into each request, the server groups points before sending when the view is wide, and the client keeps a bounded cache rather than a copy of the data. |
A burst of sign-ups never freezes the map | New sign-ups are received for the visible area, held in a buffer, and merged into the picture at most once a frame. At wide zoom a burst changes counts, not the number of things drawn. |
A pan, a zoom or a click answers within 200 milliseconds | The first paint after a move uses the previous picture, scaled, so the response does not depend on a round trip. Requests are sent once the view rests, stale ones are aborted, and recent answers are kept under an area-and-zoom key, so moving back is instant. |
Estimates
| Quantity | Working | Result | What it sizes |
|---|---|---|---|
Points in all against points a page can draw smoothly | 100,000,000 points in the data set / about 1,000,000 that deck.gl reports at 60 frames a second on a 2015 laptop = 100 | About 100 times more points than a page can draw | Why grouping must happen before the data reaches the browser. Even the 10,000,000 mark, where the same guide reports the frame rate falling to 10 to 20 a second, is a tenth of the data. |
Time budget for one frame | 1,000 ms in a second / 60 frames = about 16.7 ms | About 16.7 ms a frame | Everything the main thread does during a move, including a merge of new sign-ups, must fit inside this, which is why parsing and grouping go to a worker and redraws are tied to frames. |
Merges of live sign-ups a second | 1,000 ms / one merge per 200 ms = 5 merges a second at most | At most 5 merges a second, however many sign-ups arrive | The buffer between the connection and the canvas: a burst changes how big each batch is, not how often the canvas redraws. |
Requests during a one-second drag if each movement event sent one | Assume one movement event a frame: 60 frames a second x one second = 60 requests | About 60 requests for one drag, most for views already left | Why requests go out when the view rests and the in-flight one is aborted on the next move. |
Memory for a full view of raw points as typed arrays | Two 32-bit floats a point = 8 bytes; 1,000,000 points x 8 bytes = 8 MB | About 8 MB of positions for a million points | What a worker hands to the canvas per answer when positions are compact arrays rather than one object per point; also a scale for the cache cap. |
Core entities
| Entity | What it holds |
|---|---|
Point | One sign-up at one place and time; drawn as a dot at close zoom and opened on click. |
Cluster | A group of nearby points the server built for one zoom level; drawn as a circle with a count. |
View | What the map shows right now and which answer it is showing. |
Client cache | Recent answers kept so that moving back to a view seen a moment ago needs no request. |
Live batch | Sign-ups that arrived since the last merge, waiting for the next frame. |
The API
| Endpoint | Notes |
|---|---|
| The one data call. Bounds are the view, zoom picks the shape of the answer: clusters for a wide view, raw points for a narrow one. |
| Called on a click at close zoom. Keeping details out of the bulk answer keeps each point down to a position and an id. |
| A WebSocket in this design. Batches carry the version they bring the client up to, so a gap after a dropped connection is detectable. |
| Sent when the view rests, so the server pushes sign-ups for that area and, at wide zoom, can send count changes instead of points. |
The high-level design
Step 1 of 4
Ask by view, draw on a canvas
Start with the shape that already respects the scale: the map view sends its bounds and zoom, the server answers with clusters for a wide view or points for a narrow one, and a single canvas layer draws them. A click at close zoom opens a detail panel that fetches one point by id. This already avoids the two big mistakes, a download of the whole set and a page element per point. It still fetches on each movement, keeps nothing, and parses each answer on the main thread.
What breaks first
The deep dives
Far more points than the page can hold. Someone opens the map at world zoom, so the view contains every sign-up there has ever been. What does the page request, what comes back, and what does the canvas draw?
New sign-ups arriving live. A campaign launches and sign-ups flood in from one country, far more in a minute than a normal day brings. How does each one travel from the server to a change on the map, and what keeps the map moving while they do?
Panning and zooming. Someone drags the map across an ocean, zooms into a city, then straight back out, all inside a couple of seconds. What does the page request along the way, and what is on screen while the answers travel?
A concept that helps here: Scheduling work on the main thread
Concepts this guide uses
Sources
- deck.gl: Performance optimization
- Mapbox supercluster README
- MDN: Using Web Workers
- MDN: Transferable objects
- web.dev: Web Vitals
- MDN: AbortController
- MDN: WebSocket
- MDN: OffscreenCanvas
- MDN: Window.requestAnimationFrame()
- MDN: Optimizing canvas
- FrontendLead Discuss: Interview frontend virtual onsite at LinkedIn