Skip to content

feat: show reference data sources as shaded areas on public maps - #552

Merged
joaquimds merged 8 commits into
mainfrom
feature/public-map-area-sources
Dec 2, 2026
Merged

joaquimds merged 8 commits into
mainfrom
feature/public-map-area-sources

Conversation

@joaquimds

Copy link
Copy Markdown
Member

Summary

Reference data ("Data") sources can now be added to a public map. They're drawn as shaded areas instead of markers.

Previously the Publish page's data source dropdown hid Data sources completely. That's why the "Make Polluters Pay Campaigns" source, which is geocoded to council areas, couldn't be added to its public map.

What's included

  • Dropdown: Data sources are listed in the Publish editor. As with other sources, adding one also adds it to the private map's marker list. This is required because public map access checks look at the map config.
  • Areas: a Data source geocoded by area code or name (not postcode) is drawn on the public map and publish preview by filtering the choropleth's existing boundary tileset to the areas its records point to. A source falls back to markers when its area set has no tileset, or on the hex map.
  • Colours: area sources alternate between the colour scheme's primary colour and a new secondary colour, added to every scheme. Trans-pride's secondary was missing its #, so it's been replaced.
    • secondaryMuted is left alone because the sidebar header already uses it.
  • Markers API: in a public map context, /api/data-sources/[id]/markers adds an areaCode to each feature of these sources.
  • Interactions:
    • hovering an area darkens it and shows the same popover as a marker, listing the area's records;
    • clicking an area selects its records and flies to the area;
    • clicking a listing for an area source zooms out far enough to show the whole area.
  • Filtering: marker filtering (timeline, past events, public filters) has moved into useVisibleMarkers, so markers and areas hide the same records.
  • Sample data: resources/dataSets/sampleCouncilCampaigns.csv, 22 made-up council campaigns on LAD25 codes. It includes two records in one council and one county code that won't geocode.

Not included

  • Records with several area codes, or codes from mixed area sets (e.g. county and district). The geocoder takes one code per record, so these stay unshaded.
  • Area layers on the private map. The source shows there as markers at each area's centre point.
  • Fitting the map to an area's bounds on click. This needs a new public endpoint for area bounds.
  • Area clicks and popovers include records hidden by public map filters. This only affects areas where some records are filtered out and others aren't.

Testing

  • npm run lint passes. New unit tests are in tests/unit/utils/dataSource.test.ts.
  • Tested manually on a local public map using the sample CSV.

🤖 Generated with Claude Code

joaquimds and others added 8 commits December 1, 2026 17:19
Data (reference data) sources can now be added to a public map from the
publish editor. Each public map colour scheme gains a secondary colour,
used for a second area layer; trans-pride's was missing its #.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reference data sources geocoded by area code or name will be drawn as
shaded areas on public maps, so the markers endpoint now sends the code
of each record's area when called in a public map context.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reference data sources geocoded by area are drawn on public maps by
filtering the choropleth boundary tileset for their area set to the
records' area codes, instead of as markers. Area sources alternate
between the colour scheme's primary and secondary colours.

The marker filtering (timeline, past events, public filters) moves into
useVisibleMarkers so markers and areas hide the same records.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hovering a shaded area darkens it, clicking it selects every record
geocoded to that area, and clicking a listing for an area source zooms
out far enough to see the area.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Matches clicking a marker: centre on the area, zooming in no further
than needed to see all of it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hovering a shaded area shows the same popover as a marker, listing the
names (and dates, where shown) of the records in that area, up to five.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Area shading, hover and click now share one index of each area-drawn
source's visible records, so filtered-out records no longer appear in the
popover or selection. Also zoom listings by how a source is actually drawn,
avoid rescanning markers on every mouse move, and move area constants and
helpers to their own files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joaquimds
joaquimds merged commit 6c60197 into main Dec 2, 2026
1 check passed
@joaquimds
joaquimds deleted the feature/public-map-area-sources branch December 2, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant