Skip to content

Commit 6cf13f1

Browse files
committed
QA feedback - Prevent map cloning at low zoom
1 parent 9992b63 commit 6cf13f1

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/web-forms/src/components/common/map/useMapBlock.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { fromLonLat } from 'ol/proj';
1717
import { OSM } from 'ol/source';
1818
import VectorSource from 'ol/source/Vector';
1919
import { computed, shallowRef, watch } from 'vue';
20+
import { get as getProjection } from 'ol/proj';
2021

2122
type GeometryType = LineString | Point | Polygon;
2223

@@ -27,6 +28,7 @@ const STATES = {
2728
} as const;
2829

2930
const DEFAULT_GEOJSON_PROJECTION = 'EPSG:4326';
31+
const DEFAULT_VIEW_PROJECTION = 'EPSG:3857';
3032
const DEFAULT_VIEW_CENTER = [0, 0];
3133
const MAX_ZOOM = 16;
3234
const MIN_ZOOM = 2;
@@ -66,7 +68,14 @@ export function useMapBlock() {
6668
mapInstance = new Map({
6769
target: mapContainer,
6870
layers: [new TileLayer({ source: new OSM() }), featuresVectorLayer],
69-
view: new View({ center: DEFAULT_VIEW_CENTER, zoom: MIN_ZOOM }),
71+
view: new View({
72+
center: DEFAULT_VIEW_CENTER,
73+
zoom: MIN_ZOOM,
74+
// Prevent map cloning at low zoom during panning, which disrupts feature selection.
75+
multiWorld: false,
76+
projection: DEFAULT_VIEW_PROJECTION,
77+
extent: getProjection(DEFAULT_VIEW_PROJECTION)?.getExtent(),
78+
}),
7079
controls: [new Zoom()],
7180
});
7281

0 commit comments

Comments
 (0)