Skip to content

Update OpenLayers version and support non-built-in projections#7290

Merged
geographika merged 1 commit into
MapServer:mainfrom
geographika:ol-update-with-proj
Jun 9, 2025
Merged

Update OpenLayers version and support non-built-in projections#7290
geographika merged 1 commit into
MapServer:mainfrom
geographika:ol-update-with-proj

Conversation

@geographika
Copy link
Copy Markdown
Member

The OpenLayers template added in #7218 works fine when a request is made using one of the built-in OpenLayers projections - EPSG:4326 or EPSG:3857, however for other projections when using WMS requests and &FORMAT=application/openlayers OpenLayers throws an error:

TypeError: Cannot read properties of null (reading 'getAxisOrientation')
# at following line as projection is null
const axisOrientation = projection.getAxisOrientation();

This PR adds an additional JS check to prevent this error, by ensuring the code is registered with OpenLayers. As the map only shows layers from MapServer the actual projections don't need to have any further details (which would get very complicated and require proj4js to be included and fulll PROJ definitions to be sent back).

The check is as follows:

if (!ol.proj.get('EPSG:2157')) {
 ol.proj.addProjection(new ol.proj.Projection({ code : 'EPSG:2157' }));
}

If the projection is already supported by OpenLayers no changes are made.

The PR also includes a test, and bumps up the inbuilt OL version to a custom build based on v10.5.0 of OpenLayers, with additional ol.proj objects added (see geographika/ol-mapserver@ee41192). PR to the docs repo to follow.

@geographika geographika merged commit 9d0e102 into MapServer:main Jun 9, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant