diff --git a/packages/landing/src/map.ts b/packages/landing/src/map.ts index cdd3c6abd..e68899668 100644 --- a/packages/landing/src/map.ts +++ b/packages/landing/src/map.ts @@ -11,6 +11,7 @@ import TileSource from 'ol/source/Tile'; import BaseEvent from 'ol/events/Event'; import { ImageTile } from 'ol'; import { gaEvent, GaEvent } from './config'; +import { Extent } from 'ol/extent'; /** Projection to use for the URL bar */ const UrlProjection = Epsg.Wgs84.toEpsgString(); @@ -18,7 +19,7 @@ const UrlProjection = Epsg.Wgs84.toEpsgString(); /** Default center point if none provided */ const DefaultCenter: Record = { [Epsg.Google.code]: { lat: -41.88999621, lon: 174.04924373, zoom: 6 }, - [Epsg.Nztm2000.code]: { lat: -41.277848, lon: 174.6763921, zoom: 2 }, + [Epsg.Nztm2000.code]: { lat: -41.277848, lon: 174.6763921, zoom: 3 }, }; export interface TileLoadEvent extends BaseEvent { @@ -81,10 +82,18 @@ export class Basemaps { const loc = proj.transform([location.lon, location.lat], UrlProjection, `EPSG:${projection}`); let resolutions: undefined | number[] = undefined; + let extent: undefined | Extent = undefined; if (projection == Epsg.Nztm2000) { resolutions = NztmOl.resolutions; + extent = NztmOl.extent; } - const view = new View({ projection: projection.toEpsgString(), center: loc, zoom: location.zoom, resolutions }); + const view = new View({ + projection: projection.toEpsgString(), + center: loc, + zoom: location.zoom, + resolutions, + extent, + }); const source = this.getSource(); source.addEventListener('tileloadstart', this.trackTileLoad); diff --git a/packages/landing/src/nztm2000.ts b/packages/landing/src/nztm2000.ts index daf5b86e6..677d0607d 100644 --- a/packages/landing/src/nztm2000.ts +++ b/packages/landing/src/nztm2000.ts @@ -1,4 +1,5 @@ import { Nztm2000Tms } from '@basemaps/geo/build/tms/nztm2000'; +import { Extent } from 'ol/extent'; import { register } from 'ol/proj/proj4'; import WMTSTileGrid from 'ol/tilegrid/WMTS.js'; import Proj from 'proj4'; @@ -14,9 +15,18 @@ const origin = [topLeft[1], topLeft[0]]; // NZTM is defined as y,x not x,y const resolutions = Nztm2000Tms.zooms.map((c, i) => Nztm2000Tms.pixelScale(i)); const matrixIds = Nztm2000Tms.zooms.map((c) => c.identifier); +const { lowerCorner, upperCorner } = Nztm2000Tms.def.boundingBox; +const extent: Extent = [ + lowerCorner[Nztm2000Tms.indexX], + lowerCorner[Nztm2000Tms.indexY], + upperCorner[Nztm2000Tms.indexX], + upperCorner[Nztm2000Tms.indexY], +]; + export const NztmOl = { resolutions, origin, matrixIds, + extent, TileGrid: new WMTSTileGrid({ origin, resolutions, matrixIds }), };