Skip to content
23 changes: 23 additions & 0 deletions resources/dataSets/sampleCouncilCampaigns.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Campaign name,Council,Council code,Status,Lead group,Description,Website,Launch date
Clean Air Bristol,"Bristol, City of",E06000023,Active,Bristol Climate Network,Pushing the council to extend the clean air zone to the whole city.,https://example.org/clean-air-bristol,2026-02-14
Brighton Divest Now,Brighton and Hove,E06000043,Won,Divest Sussex,Council pension fund committed to divest from fossil fuels.,https://example.org/brighton-divest,2025-09-03
Cornwall Retrofit Drive,Cornwall,E06000052,Active,Kernow Homes Coalition,Calling for a retrofit programme for council housing.,https://example.org/cornwall-retrofit,2026-04-22
Cambridge Bus Fares,Cambridge,E07000008,Planning,Cambridge Transport Action,Campaign for capped bus fares across the city.,https://example.org/cambridge-buses,2026-10-01
Exeter Solar Schools,Exeter,E07000041,Active,Devon Energy Collective,Solar panels on every council-run school roof.,https://example.org/exeter-solar,2026-01-18
Norwich Green Spaces,Norwich,E07000148,Won,Norwich Parks Alliance,Protected three parks from development.,https://example.org/norwich-green,2025-06-30
Oxford Low Traffic,Oxford,E07000178,Active,Oxford Streets for People,Expanding low traffic neighbourhoods.,https://example.org/oxford-ltn,2026-03-09
Manchester Make Polluters Pay,Manchester,E08000003,Active,Greater Manchester Climate Action,Levy on large polluters to fund local climate action.,https://example.org/manchester-mpp,2026-05-12
Manchester Warm Homes,Manchester,E08000003,Planning,Manchester Tenants Union,Insulation for every council home by 2030.,https://example.org/manchester-warm,2026-11-20
Liverpool Waterfront Watch,Liverpool,E08000012,Active,Merseyside Climate Group,Opposing new fossil fuel infrastructure at the docks.,https://example.org/liverpool-waterfront,2026-07-04
Newcastle Heat Network,Newcastle upon Tyne,E08000021,Active,Tyneside Energy Democracy,Publicly owned district heating for the city centre.,https://example.org/newcastle-heat,2025-11-15
Birmingham Bike Lanes,Birmingham,E08000025,Won,Brum Cycle Campaign,Segregated cycle lanes on five main roads.,https://example.org/brum-bikes,2025-04-08
Leeds Airport Expansion,Leeds,E08000035,Active,Leeds Climate Coalition,Stopping the airport expansion.,https://example.org/leeds-airport,2026-02-27
Sheffield Street Trees,Sheffield,E08000039,Won,Sheffield Tree Action,Ended the felling of healthy street trees.,https://example.org/sheffield-trees,2025-03-21
Hackney Play Streets,Hackney,E09000012,Active,Hackney Families for Clean Air,School streets outside every primary school.,https://example.org/hackney-play,2026-06-16
Lambeth Community Energy,Lambeth,E09000022,Planning,Brixton Energy Co-op,Community-owned solar on council estates.,https://example.org/lambeth-energy,2026-09-05
Belfast Climate Commission,Belfast,N09000003,Active,Belfast Climate Alliance,Holding the council to its net zero plan.,https://example.org/belfast-climate,2026-01-30
Highland Wind Share,Highland,S12000017,Active,Highland Community Power,Community stake in new onshore wind.,https://example.org/highland-wind,2025-10-12
Glasgow Free Transport,Glasgow City,S12000049,Active,Get Glasgow Moving,Free public transport for under 25s.,https://example.org/glasgow-transport,2026-08-19
Swansea Tidal Power,Swansea,W06000011,Planning,Swansea Bay Energy,Revive the tidal lagoon as a public project.,https://example.org/swansea-tidal,2026-12-01
Cardiff Food Growing,Cardiff,W06000015,Active,Cardiff Food Council,Allotments and growing spaces in every ward.,https://example.org/cardiff-food,2026-04-03
West Sussex Gas Drilling,West Sussex,E10000032,Active,Frack Free Sussex,Opposing new oil and gas drilling sites (county council: will not geocode against LAD25).,https://example.org/west-sussex-drilling,2026-05-28
9 changes: 8 additions & 1 deletion src/app/(private)/map/[id]/atoms/hoverAtoms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ export const hoverSecondaryAreaAtom = atom<{
coordinates: [number, number];
} | null>(null);

export interface HoverMarkerItem {
name: string;
/** Formatted record date, when the public map shows dates */
date?: string;
}

/** The marker, or public map area, under the cursor: one item per record */
export const hoverMarkerAtom = atom<{
coordinates: [number, number];
properties: Record<string, unknown>;
items: HoverMarkerItem[];
} | null>(null);
84 changes: 84 additions & 0 deletions src/app/(private)/map/[id]/components/DataSourceAreas.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { useMemo } from "react";
import { Layer, Source } from "react-map-gl/mapbox";
import {
DATA_SOURCE_AREAS_FILL_OPACITY,
DATA_SOURCE_AREAS_HOVER_FILL_OPACITY,
DATA_SOURCE_AREAS_TOP_LAYER_ID,
} from "../constants";
import { getDataSourceAreasIds } from "../utils/dataSourceAreas";
import type { ChoroplethLayerConfig } from "./Choropleth/configs";
import type { VisibleMarkerFeature } from "../hooks/useVisibleMarkers";

/**
* Shades the areas a public map's reference data source was geocoded to,
* using the same boundary tilesets as the choropleth.
*/
export default function DataSourceAreas({
dataSourceId,
areaMarkers,
layerConfig,
color,
}: {
dataSourceId: string;
/** The source's visible records by area code (useDataSourceAreaMarkers) */
areaMarkers: Map<string, VisibleMarkerFeature[]> | undefined;
layerConfig: ChoroplethLayerConfig;
color: string;
}) {
const areaCodes = useMemo(
() => [...(areaMarkers?.keys() ?? [])],
[areaMarkers],
);

const { sourceId, layerId, featureCodeProperty } = layerConfig.mapbox;
const {
sourceId: areasSourceId,
fillLayerId,
lineLayerId,
} = getDataSourceAreasIds(dataSourceId);
const filter = ["in", ["get", featureCodeProperty], ["literal", areaCodes]];

return (
<Source
id={areasSourceId}
key={`${areasSourceId}-${sourceId}`}
promoteId={featureCodeProperty}
type="vector"
url={`mapbox://${sourceId}`}
>
<Layer
id={fillLayerId}
beforeId={DATA_SOURCE_AREAS_TOP_LAYER_ID}
source={areasSourceId}
source-layer={layerId}
type="fill"
filter={filter}
paint={{
"fill-color": color,
"fill-opacity": [
"case",
["boolean", ["feature-state", "hover"], false],
DATA_SOURCE_AREAS_HOVER_FILL_OPACITY,
DATA_SOURCE_AREAS_FILL_OPACITY,
],
}}
/>
<Layer
id={lineLayerId}
beforeId={DATA_SOURCE_AREAS_TOP_LAYER_ID}
source={areasSourceId}
source-layer={layerId}
type="line"
filter={filter}
paint={{
"line-color": color,
"line-width": 1.5,
}}
layout={{
"line-cap": "round",
"line-join": "round",
}}
/>
</Source>
);
}
23 changes: 23 additions & 0 deletions src/app/(private)/map/[id]/components/DataSourceAreasPosition.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Layer, Source } from "react-map-gl/mapbox";
import { DATA_SOURCE_AREAS_TOP_LAYER_ID } from "../constants";

/**
* Empty layer that fixes where area fills sit in the layer stack: area
* layers are inserted before it, so they stay below markers that are added
* later, whatever order the data loads in.
*/
export default function DataSourceAreasPosition() {
return (
<Source
id={DATA_SOURCE_AREAS_TOP_LAYER_ID}
type="geojson"
data={{ type: "FeatureCollection", features: [] }}
>
<Layer
id={DATA_SOURCE_AREAS_TOP_LAYER_ID}
source={DATA_SOURCE_AREAS_TOP_LAYER_ID}
type="circle"
/>
</Source>
);
}
32 changes: 23 additions & 9 deletions src/app/(private)/map/[id]/components/MarkerPopup.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Popup } from "react-map-gl/mapbox";
import { HOVER_POPUP_MAX_ITEMS } from "../constants";
import { useHoverMarker } from "../hooks/useMapHover";
import type { HoverMarkerItem } from "../atoms/hoverAtoms";

export default function MarkerPopup() {
const [hoverMarker] = useHoverMarker();
Expand All @@ -13,25 +15,37 @@ export default function MarkerPopup() {

function WrappedMarkerPopup({
coordinates,
properties,
items,
}: {
coordinates: [number, number];
properties: Record<string, unknown>;
items: HoverMarkerItem[];
}) {
const date = properties.date ? String(properties.date) : "";
const shownItems = items.slice(0, HOVER_POPUP_MAX_ITEMS);
const moreCount = items.length - shownItems.length;

return (
<Popup
longitude={coordinates[0]}
latitude={coordinates[1]}
closeButton={false}
>
<p className="font-sans font-semibold text-sm">
{String(properties.name)}
</p>
{date && (
<p className="font-sans text-xs text-muted-foreground">{date}</p>
)}
<div className="flex flex-col gap-1">
{shownItems.map((item, index) => (
<div key={index}>
<p className="font-sans font-semibold text-sm">{item.name}</p>
{item.date && (
<p className="font-sans text-xs text-muted-foreground">
{item.date}
</p>
)}
</div>
))}
{moreCount > 0 && (
<p className="font-sans text-xs text-muted-foreground">
and {moreCount} more
</p>
)}
</div>
</Popup>
);
}
105 changes: 5 additions & 100 deletions src/app/(private)/map/[id]/components/Markers/DataSourceMarkers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,9 @@ import {
MarkerIconMode,
MarkerSizeMode,
} from "@/models/MapView";
import {
getEventDateFormat,
getHidePastEvents,
getPastEventsCutoff,
isPastEvent,
parseDateValue,
} from "@/utils/dataRecord";
import { useDataSourceColumn } from "../../hooks/useDataSourceColumn";
import { useMapRoute } from "../../hooks/useMapCore";
import { PAST_EVENTS_FILTER_KEY } from "../../publish/dateFilters";
import {
useFilteredRecords,
usePublicDateFilter,
usePublicFilters,
} from "../../publish/hooks/usePublicFilters";
import { useVisibleMarkers } from "../../hooks/useVisibleMarkers";
import {
useColorScheme,
usePublicMapValue,
Expand All @@ -47,7 +35,6 @@ import { MARKER_CLIENT_EXCLUDED_KEY } from "./utils";
import type { MarkerPinStyle } from "./PinsLayer";
import type { MarkerVisualisation } from "@/models/MapView";
import type { MarkerFeature } from "@/types";
import type { FeatureCollection } from "geojson";

const NOT_MATCHED_CASE = [
"any",
Expand Down Expand Up @@ -81,100 +68,18 @@ export function DataSourceMarkers({
* two-tone style (see ClustersLayer) */
onChoropleth?: boolean;
}) {
const filteredRecords = useFilteredRecords();
const publicFilters = usePublicFilters();
const publicDateFilter = usePublicDateFilter();
const publicMap = usePublicMapValue();
const colorScheme = useColorScheme();
const publicMapLayout = isPublicMapLayout(useMapRoute());

const dataSourceId = dataSourceMarkers.dataSourceId;

// Public maps that hide past events drop them at the source level (so
// cluster counts stay correct), unless the "Past events" filter is active,
// in which case the client-filter exclusion below handles it.
const { getDataSourceById } = useDataSources();
const dataSource = getDataSourceById(dataSourceId);
const dataSourceConfig = publicMap?.dataSourceConfigs.find(
(c) => c.dataSourceId === dataSourceId,
);
const hidePastEvents =
Boolean(publicMap) && getHidePastEvents({ dataSource, dataSourceConfig });
const eventDateFormat = getEventDateFormat({ dataSource, dataSourceConfig });
const showingPastEvents =
publicDateFilter[dataSourceId] === PAST_EVENTS_FILTER_KEY;

const safeMarkers = useMemo<FeatureCollection>(() => {
const hasClientFilters =
Object.keys(publicFilters).length > 0 ||
Object.values(publicDateFilter).some(Boolean);

let features = dataSourceMarkers.markers;

// When hideFilteredMarkers is true, remove server-side unmatched markers
if (hideFilteredMarkers) {
features = features.filter((f) => f.properties.matched !== false);
}

// Timeline filter: features must be dropped at the source level (not via
// layer filters) so cluster counts stay correct. Records without a
// parseable month are hidden while the filter is active.
if (filterTimeRange !== null) {
features = features.filter(
(f) =>
typeof f.properties.month === "number" &&
f.properties.month >= filterTimeRange.start &&
f.properties.month <= filterTimeRange.end,
);
}

if (hidePastEvents && !showingPastEvents) {
// Parsed here (not on the server) so the cutoff and the date share the
// visitor's timezone, matching the listing in useFilteredRecords.
const cutoff = getPastEventsCutoff();
features = features.filter(
(f) =>
!isPastEvent(
parseDateValue(f.properties.dateValue, eventDateFormat),
cutoff,
),
);
}

if (!hasClientFilters) {
return {
type: "FeatureCollection",
features,
};
}

const recordIds = (filteredRecords || [])
.map((r: { id: string | number }) => r.id)
.filter(Boolean);

const mappedFeatures = features.map((f) => ({
...f,
properties: {
...f.properties,
[MARKER_CLIENT_EXCLUDED_KEY]: !recordIds.includes(f.properties.id),
},
}));
const dataSourceId = dataSourceMarkers.dataSourceId;

return {
type: "FeatureCollection",
features: mappedFeatures,
};
}, [
dataSourceMarkers.markers,
filteredRecords,
publicFilters,
publicDateFilter,
const safeMarkers = useVisibleMarkers({
dataSourceMarkers,
hideFilteredMarkers,
filterTimeRange,
hidePastEvents,
showingPastEvents,
eventDateFormat,
]);
});

const sourceId = `${dataSourceId}-markers`;
const publicMapColor =
Expand Down
Loading
Loading