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

build(deps): upgrade Open Layers #474

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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: 0 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ <h1 style="color:red;font-size:16px;">
ariaLabelOlFixedOverlay="Interactive example map"
zoom="20"
maxZoom="23"
basemap="MapboxSatellite"
drawMode
drawMany
drawType="Polygon"
osCopyright="© Crown copyright and database rights 2024 OS (0)100024857"
osProxyEndpoint="https://api.editor.planx.dev/proxy/ordnance-survey"
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"govuk-frontend": "^5.4.0",
"jspdf": "^2.5.1",
"lit": "^3.0.1",
"ol": "^9.1.0",
"ol": "^9.2.4",
"ol-ext": "^4.0.21",
"ol-mapbox-style": "^12.3.0",
"ol-mapbox-style": "^12.3.4",
"postcode": "^5.1.0",
"proj4": "^2.11.0",
"rambda": "^9.2.1"
Expand All @@ -45,7 +45,7 @@
"@testing-library/user-event": "^14.5.2",
"@types/file-saver": "^2.0.7",
"@types/node": "22.0.3",
"@types/ol-ext": "npm:@siedlerchr/types-ol-ext@^3.3.0",
"@types/ol-ext": "npm:@siedlerchr/types-ol-ext@^3.4.0",
"@types/proj4": "^2.5.5",
"@vitest/ui": "^0.34.7",
"happy-dom": "^9.1.9",
Expand Down
42 changes: 21 additions & 21 deletions pnpm-lock.yaml

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

15 changes: 9 additions & 6 deletions src/components/my-map/snapping.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Feature } from "ol";
import { FeatureLike } from "ol/Feature";
import { Geometry } from "ol/geom";
import Point from "ol/geom/Point";
import { Vector as VectorLayer } from "ol/layer";
import VectorTileLayer from "ol/layer/VectorTile";
import VectorSource from "ol/source/Vector";
import { Fill, Style } from "ol/style";
import CircleStyle from "ol/style/Circle";
import { splitEvery } from "rambda";

export const pointsSource = new VectorSource({
export const pointsSource: VectorSource<Feature<Geometry>> = new VectorSource({
features: [],
wrapX: false,
});
Expand All @@ -28,21 +29,23 @@ export const pointsLayer = new VectorLayer({
});

/**
* Extract points that are available to snap to when a VectorTileLayer basemap is displayed
* @param basemap - a VectorTileLayer
* Extract points that are available to snap to when an OS VectorLayer basemap is displayed
* @param basemap - a VectorLayer
* @param extent - an array of 4 points
* @returns - a VectorSource populated with points within the extent
*/
export function getSnapPointsFromVectorTiles(
basemap: VectorTileLayer,
basemap: VectorLayer,
extent: number[],
) {
const points =
basemap &&
basemap
.getSource()
?.getFeaturesInExtent(extent)
?.filter((feature) => feature.getGeometry()?.getType() !== "Point")
?.filter(
(feature: FeatureLike) => feature.getGeometry()?.getType() !== "Point",
)
?.flatMap((feature: any) => feature.flatCoordinates_);

if (points) {
Expand Down