UNPKG

1.1 kBJavaScriptView Raw
1goog.require('ol.Map');
2goog.require('ol.View');
3goog.require('ol.extent');
4goog.require('ol.layer.Image');
5goog.require('ol.layer.Tile');
6goog.require('ol.proj');
7goog.require('ol.source.ImageStatic');
8goog.require('ol.source.OSM');
9
10
11proj4.defs('EPSG:27700', '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 ' +
12 '+x_0=400000 +y_0=-100000 +ellps=airy ' +
13 '+towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 ' +
14 '+units=m +no_defs');
15var imageExtent = [0, 0, 700000, 1300000];
16
17var map = new ol.Map({
18 layers: [
19 new ol.layer.Tile({
20 source: new ol.source.OSM()
21 }),
22 new ol.layer.Image({
23 source: new ol.source.ImageStatic({
24 url: 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/18/' +
25 'British_National_Grid.svg/2000px-British_National_Grid.svg.png',
26 crossOrigin: '',
27 projection: 'EPSG:27700',
28 imageExtent: imageExtent
29 })
30 })
31 ],
32 target: 'map',
33 view: new ol.View({
34 center: ol.proj.transform(
35 ol.extent.getCenter(imageExtent), 'EPSG:27700', 'EPSG:3857'),
36 zoom: 4
37 })
38});