Skip to content

Commit

Permalink
feat: display static map for inactive List "map" fields (#3568)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak authored Aug 27, 2024
1 parent 7bbd1c0 commit effb072
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
4 changes: 3 additions & 1 deletion editor.planx.uk/src/@planx/components/List/Public/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ const InactiveListCard: React.FC<{
<TableBody>
{schema.fields.map((field, j) => (
<TableRow key={`tableRow-${j}`}>
<TableCell sx={{ fontWeight: FONT_WEIGHT_SEMI_BOLD }}>
<TableCell
sx={{ fontWeight: FONT_WEIGHT_SEMI_BOLD, maxWidth: "100px" }}
>
{field.data.title}
</TableCell>
<TableCell>
Expand Down
54 changes: 54 additions & 0 deletions editor.planx.uk/src/@planx/components/List/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,60 @@ export function formatSchemaDisplayValue(
);
return matchingOption?.data.text;
}
case "map": {
const feature = value[0] as string as any; // won't be necessary to cast once we're only setting "geojsonData" prop in future
const drawType = field.data.mapOptions?.drawType;

switch (drawType) {
case "Point":
// Our "geojsonData" layer doesn't have a "point" style yet, so make due with center marker for now!
// Once style layers are more comprehensive, share same map as "Polygon" style here
return (
<>
{/* @ts-ignore */}
<my-map
id="inactive-list-map"
latitude={feature.geometry.coordinates[1]}
longitude={feature.geometry.coordinates[0]}
zoom={19}
showCentreMarker
markerLatitude={feature.geometry.coordinates[1]}
markerLongitude={feature.geometry.coordinates[0]}
markerColor={field.data.mapOptions?.drawColor}
osProxyEndpoint={`${
import.meta.env.VITE_APP_API_URL
}/proxy/ordnance-survey`}
hideResetControl
staticMode
style={{ width: "100%", height: "30vh" }}
osCopyright={`© Crown copyright and database rights ${new Date().getFullYear()} OS (0)100024857`}
collapseAttributions
/>
</>
);
case "Polygon":
return (
<>
{/* @ts-ignore */}
<my-map
id="inactive-list-map"
geojsonData={JSON.stringify(feature)}
geojsonColor={field.data.mapOptions?.drawColor}
geojsonFill
geojsonBuffer={20}
osProxyEndpoint={`${
import.meta.env.VITE_APP_API_URL
}/proxy/ordnance-survey`}
hideResetControl
staticMode
style={{ width: "100%", height: "30vh" }}
osCopyright={`© Crown copyright and database rights ${new Date().getFullYear()} OS (0)100024857`}
collapseAttributions
/>
</>
);
}
}
}
}

Expand Down

0 comments on commit effb072

Please sign in to comment.