Skip to content

Commit 5e5203e

Browse files
committed
DBC22-3567: adjusted extent and zoom for report map
1 parent 88e5809 commit 5e5203e

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/frontend/src/Components/report/ReportMap.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import overrides from '../map/overrides.js';
2626
// OpenLayers
2727
import { applyStyle } from 'ol-mapbox-style';
2828
import { defaults } from 'ol/control.js';
29-
import { fromLonLat, transform } from 'ol/proj';
29+
import { fromLonLat, transform, transformExtent } from 'ol/proj';
3030
import { ImageWMS, Vector as VectorSource } from 'ol/source.js';
3131
import { Image as ImageLayer, Vector as VectorLayer } from 'ol/layer.js';
3232
import { Polygon } from 'ol/geom';
@@ -88,6 +88,10 @@ function loadReportMap(setActiveFeature, wmsLayer, styles) {
8888
});
8989
});
9090

91+
// Set map extent (W, S, E, N)
92+
const extent = [-169.9999311184518, 14.504609139675608, -60.70077056146753, 75.20528693014171];
93+
const transformedExtent = transformExtent(extent, 'EPSG:4326', 'EPSG:3857');
94+
9195
const mapViewObj = new View({
9296
// Centered on BC
9397
center: transform(
@@ -96,6 +100,9 @@ function loadReportMap(setActiveFeature, wmsLayer, styles) {
96100
'EPSG:3857',
97101
),
98102
zoom: 5,
103+
maxZoom: 15,
104+
minZoom: 4,
105+
extent: transformedExtent,
99106
});
100107

101108
const newMap = new Map({
@@ -225,7 +232,7 @@ export function ReportMap(props) {
225232
) {
226233
const mapCoords = fromLonLat([longitude, latitude]);
227234

228-
setZoomPan(mapView, 6, mapCoords);
235+
setZoomPan(mapView, 5, mapCoords);
229236
setLocationPin([longitude, latitude], redLocationMarkup, mapRef);
230237

231238
// Wait for map to pan before getting pixel coords
@@ -239,10 +246,10 @@ export function ReportMap(props) {
239246
wmsLayer,
240247
);
241248
}, 1000);
249+
242250
} else {
243251
// set my location to the center of BC for users outside of BC
244252
setZoomPan(mapView, 9, fromLonLat([-126.5, 54.2]));
245-
246253
}
247254

248255
const end = performance.now();

0 commit comments

Comments
 (0)