From 9e8d49e48535766fad5f031d2a9dd811c580242f Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Sun, 27 Sep 2020 15:14:59 +0100 Subject: [PATCH] Display current OS copyright date Display current OS copyright date to keep up with source updates https://www.arcgis.com/home/item.html?id=7561029c176d43d09a5aa1180ada309a Increase EPSG:27700 extent beyond the usual definition to the visible extent of the OS Overview layer --- examples/reprojection.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/reprojection.js b/examples/reprojection.js index d6d2d77acf..461adf0c41 100644 --- a/examples/reprojection.js +++ b/examples/reprojection.js @@ -7,7 +7,7 @@ import WMTSCapabilities from '../src/ol/format/WMTSCapabilities.js'; import proj4 from 'proj4'; import {OSM, TileImage, TileWMS} from '../src/ol/source.js'; import {getCenter, getWidth} from '../src/ol/extent.js'; -import {get as getProjection} from '../src/ol/proj.js'; +import {get as getProjection, transformExtent} from '../src/ol/proj.js'; import {register} from '../src/ol/proj/proj4.js'; proj4.defs( @@ -51,7 +51,7 @@ proj4.defs( register(proj4); const proj27700 = getProjection('EPSG:27700'); -proj27700.setExtent([0, 0, 700000, 1300000]); +proj27700.setExtent([-650000, -150000, 1350000, 1450000]); const proj23032 = getProjection('EPSG:23032'); proj23032.setExtent([-1206118.71, 4021309.92, 1295389.0, 8051813.28]); @@ -139,7 +139,8 @@ fetch(urlB) layer: 'OS_Open_Raster', }); options.attributions = - 'Contains OS data © Crown Copyright and database right 2019'; + 'Contains OS data © Crown Copyright and database right ' + + new Date().getFullYear(); options.crossOrigin = ''; options.projection = 'EPSG:27700'; options.wrapX = false; @@ -195,8 +196,10 @@ function updateViewProjection() { map.setView(newView); // Example how to prevent double occurrence of map by limiting layer extent - if (newProj == getProjection('EPSG:3857')) { - layers['bng'].setExtent([-1057216, 6405988, 404315, 8759696]); + if (newProj.isGlobal()) { + layers['bng'].setExtent( + transformExtent(proj27700.getExtent(), proj27700, newProj, 2) + ); } else { layers['bng'].setExtent(undefined); }