I have a problem with getting a map in EPSG 3031 to work.
From my research I have already learned that the parameters for the projection have to be defined in the javascript file, which accordingly to epsg.io works fine in my script.
But when I use the actual EPSG:3031 in my new created View and my transformed center the map does not render. The only way it works is selecting EPSG:4326 or 3857 with the center [0,0] what actually doesn't make any sense.
My javascript looks like this:
// register EPSG
proj4.defs("EPSG:3031","+proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs");
//set projection
var proj3031=ol.proj.get('EPSG:3031');
//test if coordinate transformation is properly working
var center2 = ol.proj.transform([0, -80], 'EPSG:4326', 'EPSG:3031');
;
var baseMapLayer = new ol.layer.Tile({
source: new ol.source.OSM()
});
var esriArctic = new ol.layer.Tile({
title : 'ESRI Imagery',
type : 'base',
zIndex: 0,
source : new ol.source.XYZ({
attributions : [new ol.Attribution({
html : 'Tiles © <a href="http://services.arcgisonline.com/ArcGIS/rest/services/Polar/Antarctic_Imagery/MapServer">ArcGIS</a>'
})],
url : 'https://server.arcgisonline.com/ArcGIS/rest/services/Polar/Antarctic_Imagery/MapServer/tile/{z}/{y}/{x}',
wrapX: false,
})
});
var map = new ol.Map({
target: 'map',
layers: [ esriArctic],
//layers: [ baseMapLayer],
view: new ol.View({
//projection: "EPSG:4326",
projection: proj3031,
//center: [0,0],
center: center2,
zoom: 5 //Initial Zoom Level
})
});
And my html looks like this:
<!DOCTYPE html>
<style type="text/css">
#map{
width:100%;
height:600px;
}
</style>
<!--Basic styling for map div,
if height is not defined the div will show up with 0 px height -->
</head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.3/proj4.js"></script>
<script src="http://epsg.io/3031.js"></script>
<body>
<div id="map">
<!-- Your map will be shown inside this div-->
</div>
</body>
<script src="https://openlayers.org/en/v4.6.5/build/ol.js" type="text/javascript"></script>
<script type="text/javascript" src="map.js" type="text/javascript"></script>
<!-- Our map file -->
</html>>
<!-- Openlayesr JS fIle -->
How can I get this to work and why does it not work right now?