Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade to @opensystemslab/map@next v1.0.0-alpha.1 #3590

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion editor.planx.uk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@mui/lab": "5.0.0-alpha.170",
"@mui/material": "^5.15.10",
"@mui/utils": "^5.15.11",
"@opensystemslab/map": "1.0.0-alpha.0",
"@opensystemslab/map": "1.0.0-alpha.1",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#d46df8d",
"@tiptap/core": "^2.4.0",
"@tiptap/extension-bold": "^2.0.3",
Expand Down
13 changes: 7 additions & 6 deletions editor.planx.uk/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

96 changes: 29 additions & 67 deletions editor.planx.uk/src/@planx/components/List/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,70 +44,32 @@ 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"
basemap={field.data.mapOptions?.basemap}
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={
field.data.mapOptions?.basemap === "OSVectorTile"
? `© Crown copyright and database rights ${new Date().getFullYear()} OS (0)100024857`
: ``
}
mapboxAccessToken={import.meta.env.VITE_APP_MAPBOX_ACCESS_TOKEN}
collapseAttributions
/>
</>
);
case "Polygon":
return (
<>
{/* @ts-ignore */}
<my-map
id="inactive-list-map"
basemap={field.data.mapOptions?.basemap}
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={
field.data.mapOptions?.basemap === "OSVectorTile"
? `© Crown copyright and database rights ${new Date().getFullYear()} OS (0)100024857`
: ``
}
mapboxAccessToken={import.meta.env.VITE_APP_MAPBOX_ACCESS_TOKEN}
collapseAttributions
/>
</>
);
}
const feature = value[0];
return (
<>
{/* @ts-ignore */}
<my-map
id="inactive-list-map"
basemap={field.data.mapOptions?.basemap}
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={
field.data.mapOptions?.basemap === "OSVectorTile"
? `© Crown copyright and database rights ${new Date().getFullYear()} OS (0)100024857`
: ``
}
mapboxAccessToken={import.meta.env.VITE_APP_MAPBOX_ACCESS_TOKEN}
collapseAttributions
/>
</>
);
}
}
}
Expand Down Expand Up @@ -203,9 +165,9 @@ export function flatten<T extends Record<string, any>>(

return isObject && depth > 0
? {
...acc,
...flatten(value, { depth: depth - 1, path: newPath, separator }),
}
...acc,
...flatten(value, { depth: depth - 1, path: newPath, separator }),
}
: { ...acc, [newPath]: value };
}, {} as T);
}
Expand Down
Loading