diff --git a/editor.planx.uk/package.json b/editor.planx.uk/package.json index d4133e2174..a71f3c98c6 100644 --- a/editor.planx.uk/package.json +++ b/editor.planx.uk/package.json @@ -13,7 +13,7 @@ "@mui/lab": "5.0.0-alpha.170", "@mui/material": "^5.15.10", "@mui/utils": "^5.15.11", - "@opensystemslab/map": "^0.8.3", + "@opensystemslab/map": "1.0.0-alpha.0", "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#6b2fd26", "@tiptap/core": "^2.4.0", "@tiptap/extension-bold": "^2.0.3", diff --git a/editor.planx.uk/pnpm-lock.yaml b/editor.planx.uk/pnpm-lock.yaml index 346fc887ea..575f015dcf 100644 --- a/editor.planx.uk/pnpm-lock.yaml +++ b/editor.planx.uk/pnpm-lock.yaml @@ -41,8 +41,8 @@ dependencies: specifier: ^5.15.11 version: 5.15.11(@types/react@18.2.45)(react@18.2.0) '@opensystemslab/map': - specifier: ^0.8.3 - version: 0.8.3 + specifier: 1.0.0-alpha.0 + version: 1.0.0-alpha.0 '@opensystemslab/planx-core': specifier: git+https://github.com/theopensystemslab/planx-core#6b2fd26 version: github.com/theopensystemslab/planx-core/6b2fd26(@types/react@18.2.45) @@ -5662,10 +5662,10 @@ packages: resolution: {integrity: sha512-XuySG1E38YScSJoMlqovLru4KTUNSjgVTIjyh7qMX6aNN5HY5Ct5LhRJdxO79JtTzKfzV/bnWpz+zquYrISsvw==} dev: true - /@opensystemslab/map@0.8.3: - resolution: {integrity: sha512-4WS4Cow27wmffp7KLtSB/m9HtXz0UDCXJXhq9kz152ofSretWgAl7+WFbqC+CeoVx+CV7ETmbFdjoJ3yZQzJ0Q==} + /@opensystemslab/map@1.0.0-alpha.0: + resolution: {integrity: sha512-zOAo9mz4g8VOqd6Kp4Fxf4a1uCTPBYqGLLhdD/7QJjRBZN5kWxYMhymiteFPE0V5afEIPyI4nnWS2Q2RB9JnDQ==} dependencies: - '@turf/union': 6.5.0 + '@turf/union': 7.1.0 accessible-autocomplete: 2.0.4 file-saver: 2.0.5 govuk-frontend: 5.5.0 @@ -5676,7 +5676,7 @@ packages: ol-mapbox-style: 12.3.5(ol@9.2.4) postcode: 5.1.0 proj4: 2.12.0 - rambda: 8.6.0 + rambda: 9.3.0 dev: false /@petamoriken/float16@3.8.7: @@ -8343,10 +8343,6 @@ packages: tslib: 2.6.3 dev: false - /@turf/helpers@6.5.0: - resolution: {integrity: sha512-VbI1dV5bLFzohYYdgqwikdMVpe7pJ9X3E+dlr425wa2/sMJqYDhTO++ec38/pcPvPE6oD9WEEeU3Xu3gza+VPw==} - dev: false - /@turf/helpers@7.0.0: resolution: {integrity: sha512-vwZvxRuyjGpGXvhXSbT9mX6FK92dBMLWbMbDJ/MXQUPx17ReVPFc+6N6IcxAzZfkiCnqy7vpuq0c+/TTrQxIiA==} dependencies: @@ -8361,12 +8357,6 @@ packages: tslib: 2.6.3 dev: false - /@turf/invariant@6.5.0: - resolution: {integrity: sha512-Wv8PRNCtPD31UVbdJE/KVAWKe7l6US+lJItRR/HOEW3eh+U/JwRCSUl/KZ7bmjM/C+zLNoreM2TU6OoLACs4eg==} - dependencies: - '@turf/helpers': 6.5.0 - dev: false - /@turf/jsts@2.7.1: resolution: {integrity: sha512-+nwOKme/aUprsxnLSfr2LylV6eL6T1Tuln+4Hl92uwZ8FrmjDRCH5Bi1LJNVfWCiYgk8+5K+t2zDphWNTsIFDA==} dependencies: @@ -8390,12 +8380,14 @@ packages: tslib: 2.6.3 dev: false - /@turf/union@6.5.0: - resolution: {integrity: sha512-igYWCwP/f0RFHIlC2c0SKDuM/ObBaqSljI3IdV/x71805QbIvY/BYGcJdyNcgEA6cylIGl/0VSlIbpJHZ9ldhw==} + /@turf/union@7.1.0: + resolution: {integrity: sha512-7VI8jONdBg9qmbfNlLQycPr93l5aU9HGMgWI9M6pb4ERuU2+p8KgffCgs2NyMtP2HxPrKSybzj31g7bnbEKofQ==} dependencies: - '@turf/helpers': 6.5.0 - '@turf/invariant': 6.5.0 + '@turf/helpers': 7.1.0 + '@turf/meta': 7.1.0 + '@types/geojson': 7946.0.14 polygon-clipping: 0.15.7 + tslib: 2.6.3 dev: false /@types/aria-query@5.0.4: @@ -18124,8 +18116,8 @@ packages: dependencies: performance-now: 2.1.0 - /rambda@8.6.0: - resolution: {integrity: sha512-Ax+/bAcV2h4wINXx6wm0792G5uXZAl78rzhei+FqmHezg45vbeTUyDAmDNbSdjNOL6LGN8AUEvzaYD7oO5eYrw==} + /rambda@9.3.0: + resolution: {integrity: sha512-cl/7DCCKNxmsbc0dXZTJTY08rvDdzLhVfE6kPBson1fWzDapLzv0RKSzjpmAqP53fkQqAvq05gpUVHTrUNsuxg==} dev: false /ramda@0.29.0: diff --git a/editor.planx.uk/src/@planx/components/DrawBoundary/Public/index.tsx b/editor.planx.uk/src/@planx/components/DrawBoundary/Public/index.tsx index cfe8dfc3c0..44162c100f 100644 --- a/editor.planx.uk/src/@planx/components/DrawBoundary/Public/index.tsx +++ b/editor.planx.uk/src/@planx/components/DrawBoundary/Public/index.tsx @@ -88,29 +88,24 @@ export default function Component(props: Props) { if (isMounted.current) setSlots([]); isMounted.current = true; - const areaChangeHandler = ({ detail }: { detail: string }) => { - const numberString = detail.split(" ")[0]; - const area = Number(numberString); - setArea(area); - }; - const geojsonChangeHandler = ({ detail: geojson }: any) => { if (geojson["EPSG:3857"]?.features) { // only a single polygon can be drawn, so get first feature in geojson "FeatureCollection" setBoundary(geojson["EPSG:3857"].features[0]); + setArea( + geojson["EPSG:3857"].features[0]?.properties?.["area.squareMetres"], + ); } else { - // if the user clicks 'reset' to erase the drawing, geojson will be empty object, so set boundary to undefined + // if the user clicks 'reset' to erase the drawing, geojson will be empty object, so set boundary to undefined & area to 0 setBoundary(undefined); + setArea(0); } }; const map: any = document.getElementById("draw-boundary-map"); - - map?.addEventListener("areaChange", areaChangeHandler); map?.addEventListener("geojsonChange", geojsonChangeHandler); return function cleanup() { - map?.removeEventListener("areaChange", areaChangeHandler); map?.removeEventListener("geojsonChange", geojsonChangeHandler); }; }, [page, setArea, setBoundary, setSlots]); diff --git a/editor.planx.uk/src/@planx/components/FindProperty/Public/Map.tsx b/editor.planx.uk/src/@planx/components/FindProperty/Public/Map.tsx index b6f8be86b0..11dc9bf8ce 100644 --- a/editor.planx.uk/src/@planx/components/FindProperty/Public/Map.tsx +++ b/editor.planx.uk/src/@planx/components/FindProperty/Public/Map.tsx @@ -164,6 +164,7 @@ export default function PlotNewAddress(props: PlotNewAddressProps): FCReturn { showNorthArrow osProxyEndpoint={`${process.env.REACT_APP_API_URL}/proxy/ordnance-survey`} clipGeojsonData={JSON.stringify(boundaryBBox)} + osCopyright={`© Crown copyright and database rights ${new Date().getFullYear()} OS (0)100024857`} collapseAttributions={window.innerWidth < 500 ? true : undefined} /> diff --git a/editor.planx.uk/src/@planx/components/MapAndLabel/Public.tsx b/editor.planx.uk/src/@planx/components/MapAndLabel/Public.tsx index 65df63ce54..743757538c 100644 --- a/editor.planx.uk/src/@planx/components/MapAndLabel/Public.tsx +++ b/editor.planx.uk/src/@planx/components/MapAndLabel/Public.tsx @@ -1,4 +1,3 @@ -import { alpha } from "@mui/material/styles"; import Typography from "@mui/material/Typography"; import { Feature } from "geojson"; import { useStore } from "pages/FlowEditor/lib/store"; @@ -26,12 +25,6 @@ function MapAndLabelComponent(props: Props) { let count = 0; useEffect(() => { - const areaChangeHandler = ({ detail }: { detail: string }) => { - const numberString = detail.split(" ")[0]; - const area = Number(numberString); - setArea(area); - }; - const geojsonChangeHandler = ({ detail: geojson }: any) => { if (geojson["EPSG:3857"]?.features) { count++; @@ -49,12 +42,9 @@ function MapAndLabelComponent(props: Props) { }; const map: any = document.getElementById("draw-boundary-map"); - - map?.addEventListener("areaChange", areaChangeHandler); map?.addEventListener("geojsonChange", geojsonChangeHandler); return function cleanup() { - map?.removeEventListener("areaChange", areaChangeHandler); map?.removeEventListener("geojsonChange", geojsonChangeHandler); }; }, [objectArray, boundary]); @@ -79,20 +69,20 @@ function MapAndLabelComponent(props: Props) { {/* @ts-ignore */} - The property boundary you have drawn is{" "} diff --git a/editor.planx.uk/src/@planx/components/shared/Preview/SummaryList.tsx b/editor.planx.uk/src/@planx/components/shared/Preview/SummaryList.tsx index a0fb267749..fa3a6553e9 100644 --- a/editor.planx.uk/src/@planx/components/shared/Preview/SummaryList.tsx +++ b/editor.planx.uk/src/@planx/components/shared/Preview/SummaryList.tsx @@ -500,6 +500,7 @@ function DrawBoundary(props: ComponentProps) { hideResetControl staticMode style={{ width: "100%", height: "30vh" }} + osCopyright={`© Crown copyright and database rights ${new Date().getFullYear()} OS (0)100024857`} collapseAttributions />