Merge pull request #8546 from ahocevar/proj-faq
Update projection FAQ for v5
This commit is contained in:
+8
-9
@@ -65,20 +65,19 @@ var map = new ol.Map({
|
|||||||
```
|
```
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// To use other projections, you have to register the projection in OpenLayers:
|
// To use other projections, you have to register the projection in OpenLayers.
|
||||||
|
// This can easily be done with [https://proj4js.org](proj4)
|
||||||
//
|
//
|
||||||
// By default OpenLayers does not know about the EPSG:21781 (Swiss) projection.
|
// By default OpenLayers does not know about the EPSG:21781 (Swiss) projection.
|
||||||
// So we create a projection instance for EPSG:21781 and pass it to
|
// So we create a projection instance for EPSG:21781 and pass it to
|
||||||
// ol.proj.addProjection to make it available to the library for lookup by its
|
// ol.proj.addProjection to make it available to the library for lookup by its
|
||||||
// code.
|
// code.
|
||||||
var swissProjection = new ol.proj.Projection({
|
proj4.defs('EPSG:21781',
|
||||||
code: 'EPSG:21781',
|
'+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 ' +
|
||||||
// The extent is used to determine zoom level 0. Recommended values for a
|
'+x_0=600000 +y_0=200000 +ellps=bessel ' +
|
||||||
// projection's validity extent can be found at https://epsg.io/.
|
'+towgs84=660.077,13.551,369.344,2.484,1.783,2.939,5.66 +units=m +no_defs');
|
||||||
extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864],
|
ol.proj.proj4.register(proj4);
|
||||||
units: 'm'
|
var swissProjection = ol.proj.get('EPSG:21781');
|
||||||
});
|
|
||||||
ol.proj.addProjection(swissProjection);
|
|
||||||
|
|
||||||
// we can now use the projection:
|
// we can now use the projection:
|
||||||
var map = new ol.Map({
|
var map = new ol.Map({
|
||||||
|
|||||||
Reference in New Issue
Block a user