I want to use EPSG:25832 as the default projection for all my layers. The projection is not working correctly because the Position (center point) should be in Germany but I end up in France. When I want to pan to Germany I get an "InvalidStateError". I did the following:
- loaded the latest proj4j Version with
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.12/proj4-src.js"></script>
and
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.12/proj4.js"></script>
- defined the projection (parameter from http://spatialreference.org/ref/epsg/etrs89-utm-zone-32n/):
var myProjectionName = 'EPSG:25832'; proj4.defs(myProjectionName, "+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs");
- created the projection:
var myProjection = new ol.proj.Projection({ code: myProjectionName, extent: [265948.8191, 6421521.2254, 677786.3629, 7288831.7014], units: 'm' }); ol.proj.addProjection(myProjection);
I got the extent parameter also from http://spatialreference.org/ref/epsg/etrs89-utm-zone-32n/
- created the map:
var map = new ol.Map({ layers: layers, target: 'map', view: new ol.View({ projection: myProjection, // Is this necessary? center: ol.proj.transform([7.20,51.67], 'EPSG:4326', myProjectionName), zoom: 10 }) });
I saw different approaches on how the map was created (with and without the projection parameter). Is the projection needed or is it sufficient to add the "ol.proj.transform" at the Center parameter?
Before I used
center: ol.proj.transform([7.20,51.67], 'EPSG:4326', 'EPSG:3857'),
which worked fine for displaying the data. Now I am working with a WFS-T and it is necessary to use EPSG:25832. What is wrong with my projection?