Use proj4 from the proj4 package instead of the global
This commit is contained in:
@@ -7,23 +7,26 @@ import {fromLonLat} from '../src/ol/proj.js';
|
||||
import _ol_proj_Projection_ from '../src/ol/proj/Projection.js';
|
||||
import _ol_source_ImageWMS_ from '../src/ol/source/ImageWMS.js';
|
||||
import {register} from '../src/ol/proj/proj4.js';
|
||||
import proj4 from 'proj4';
|
||||
|
||||
|
||||
// Transparent Proj4js support:
|
||||
//
|
||||
// EPSG:21781 is known to Proj4js because its definition was loaded in the html.
|
||||
// Now when we create an ol.proj.Projection instance with the 'EPSG:21781' code,
|
||||
// OpenLayers will pick up parameters like units and transform functions from
|
||||
// Proj4js.
|
||||
// EPSG:21781 is known to Proj4js because its definition is registered by
|
||||
// calling proj4.defs(). Now when we create an ol/proj/Projection instance with
|
||||
// the 'EPSG:21781' code, OpenLayers will pick up the transform functions from
|
||||
// Proj4js. To get the registered ol/proj/Projection instance with other
|
||||
// parameters like units and axis orientation applied from Proj4js, use
|
||||
// `ol/proj#get('EPSG:21781')`.
|
||||
//
|
||||
// Note that we are setting the projection's extent here, which is used to
|
||||
// determine the view resolution for zoom level 0. Recommended values for a
|
||||
// projection's validity extent can be found at https://epsg.io/.
|
||||
//
|
||||
// If you use Proj4js only to transform coordinates, you don't even need to
|
||||
// create an ol.proj.Projection instance. ol.proj.get() will take care of it
|
||||
// internally.
|
||||
|
||||
proj4.defs('EPSG:21781',
|
||||
'+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 ' +
|
||||
'+x_0=600000 +y_0=200000 +ellps=bessel ' +
|
||||
'+towgs84=660.077,13.551,369.344,2.484,1.783,2.939,5.66 +units=m +no_defs');
|
||||
register(proj4);
|
||||
|
||||
var projection = new _ol_proj_Projection_({
|
||||
|
||||
Reference in New Issue
Block a user