diff --git a/examples/reprojection-by-code.html b/examples/reprojection-by-code.html index 446aee77b6..319309832a 100644 --- a/examples/reprojection-by-code.html +++ b/examples/reprojection-by-code.html @@ -7,8 +7,6 @@ docs: > OSM (EPSG:3857) to arbitrary projection by searching in EPSG.io database. tags: "reprojection, projection, proj4js, epsg.io" -resources: - - https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.4/proj4.js ---
diff --git a/examples/reprojection-by-code.js b/examples/reprojection-by-code.js index 3503d6e425..451836c0f0 100644 --- a/examples/reprojection-by-code.js +++ b/examples/reprojection-by-code.js @@ -6,6 +6,7 @@ import {get as getProjection, getTransform} from '../src/ol/proj.js'; import {register} from '../src/ol/proj/proj4.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_TileImage_ from '../src/ol/source/TileImage.js'; +import proj4 from 'proj4'; var map = new _ol_Map_({ diff --git a/examples/reprojection.html b/examples/reprojection.html index b87a7776a9..dee4de0364 100644 --- a/examples/reprojection.html +++ b/examples/reprojection.html @@ -5,8 +5,6 @@ shortdesc: Demonstrates client-side raster reprojection between various projecti docs: > This example shows client-side raster reprojection between various projections. tags: "reprojection, projection, proj4js, osm, wms, wmts, hidpi" -resources: - - https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.4/proj4.js ---
diff --git a/examples/reprojection.js b/examples/reprojection.js index c166c018c7..376e38f942 100644 --- a/examples/reprojection.js +++ b/examples/reprojection.js @@ -11,6 +11,7 @@ import _ol_source_TileWMS_ from '../src/ol/source/TileWMS.js'; import _ol_source_WMTS_ from '../src/ol/source/WMTS.js'; import _ol_source_XYZ_ from '../src/ol/source/XYZ.js'; import _ol_tilegrid_TileGrid_ from '../src/ol/tilegrid/TileGrid.js'; +import proj4 from 'proj4'; proj4.defs('EPSG:27700', '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 ' + diff --git a/examples/scaleline-indiana-east.html b/examples/scaleline-indiana-east.html index 40d9dfe109..787539cb2d 100644 --- a/examples/scaleline-indiana-east.html +++ b/examples/scaleline-indiana-east.html @@ -5,7 +5,5 @@ shortdesc: Demonstrates client-side reprojection of OpenStreetMap to NAD83 India docs: > This example shows client-side reprojection of OpenStreetMap to NAD83 Indiana East, including a ScaleLine control with US units. tags: "reprojection, projection, openstreetmap, nad83, tile, scaleline" -resources: - - https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.4/proj4.js ---
diff --git a/examples/scaleline-indiana-east.js b/examples/scaleline-indiana-east.js index 372e01299a..d203095eaa 100644 --- a/examples/scaleline-indiana-east.js +++ b/examples/scaleline-indiana-east.js @@ -5,6 +5,7 @@ import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import {fromLonLat, transformExtent} from '../src/ol/proj.js'; import {register} from '../src/ol/proj/proj4.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js'; +import proj4 from 'proj4'; proj4.defs('Indiana-East', 'PROJCS["IN83-EF",GEOGCS["LL83",DATUM["NAD83",' + 'SPHEROID["GRS1980",6378137.000,298.25722210]],PRIMEM["Greenwich",0],' + diff --git a/examples/sphere-mollweide.html b/examples/sphere-mollweide.html index 13286a4a39..f57a4ccb25 100644 --- a/examples/sphere-mollweide.html +++ b/examples/sphere-mollweide.html @@ -5,7 +5,5 @@ shortdesc: Example of a Sphere Mollweide map with a Graticule component. docs: > Example of a Sphere Mollweide map with a Graticule component. tags: "graticule, Mollweide, projection, proj4js" -resources: - - https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.4/proj4.js ---
diff --git a/examples/sphere-mollweide.js b/examples/sphere-mollweide.js index a7b79d7482..08552b07fc 100644 --- a/examples/sphere-mollweide.js +++ b/examples/sphere-mollweide.js @@ -6,6 +6,7 @@ import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; import _ol_proj_Projection_ from '../src/ol/proj/Projection.js'; import _ol_source_Vector_ from '../src/ol/source/Vector.js'; import {register} from '../src/ol/proj/proj4.js'; +import proj4 from 'proj4'; proj4.defs('ESRI:53009', '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +a=6371000 ' + diff --git a/examples/wms-image-custom-proj.html b/examples/wms-image-custom-proj.html index 9ae33190df..5e65f72590 100644 --- a/examples/wms-image-custom-proj.html +++ b/examples/wms-image-custom-proj.html @@ -5,8 +5,5 @@ shortdesc: Example of integrating Proj4js for coordinate transforms. docs: > With [Proj4js](http://proj4js.org/) integration, OpenLayers can transform coordinates between arbitrary projections. tags: "wms, single image, proj4js, projection" -resources: - - https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.4/proj4.js - - https://epsg.io/21781-1753.js ---
diff --git a/examples/wms-image-custom-proj.js b/examples/wms-image-custom-proj.js index affde84526..95ebb489c5 100644 --- a/examples/wms-image-custom-proj.js +++ b/examples/wms-image-custom-proj.js @@ -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_({