3

I'm new to GIS and OL3. My app needs to display a map in EPSG:4326 and the same app has to display a map in EPSG:3412 when I click on a button.

Here is the link for the JSFiddle http://jsfiddle.net/tmylamoule/ze9cg462/

My JS code

proj4.defs("EPSG:3412", "+proj=stere +lat_0=-90 +lat_ts=-70 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m +no_defs");
var ePSG3412Button = document.getElementById('clickMe');
var ePSG3857Button = document.getElementById('clickMe2');


var map = new ol.Map({
  target: 'map',
  layers: [
    new ol.layer.Tile({
      source: new ol.source.MapQuest({
        layer: 'sat',
        wrapX: false,
        noWrap: true,
      }),
    })
  ],
});
ePSG3412Button.addEventListener('click', function() {
  var view2 = new ol.View({
    projection: 'EPSG:3412',
    center: ol.proj.transform([0, 0], 'EPSG:3857', 'EPSG:3412'),
    zoom: 1
  });
  map.setView(view2);
});
ePSG3857Button.addEventListener('click', function() {
  var view = new ol.View({
    projection: 'EPSG:3857',
    center: ol.proj.transform([0, 0], 'EPSG:3857', 'EPSG:3857'),
    zoom: 1
  });
  map.setView(view);
});

The only thing my code is doing is center the map in the middle of each projection. But I can't manage to transform the tiles.

  • I think you cannot reproject "Image" and "Tile" sources, but I find no references in the documentation. – Giacomo Catenazzi Mar 3 '16 at 16:22
  • 1
    Hey thanks for the answer ! From what I've found link It is possible to reproject but the example in the URL won't work on jsfiddle :( – tmylamoule Mar 3 '16 at 16:26
  • You are right, I was remember wrongly. So it is possible – Giacomo Catenazzi Mar 3 '16 at 16:32
  • Yes I know it's possible but I can't make this possible in my app :( – tmylamoule Mar 4 '16 at 8:11
  • 1
    Tile reprojection is possible with the latest versions of ol3. I think 3.12 and above. Within your fiddle you use v3.0.0. try to upgrade to the latest version – pavlos Mar 4 '16 at 8:57
1

From v3.11.0 and above ol3 library supports raster reprojection on client. So tile reprojection is also possible. release notes stating this change may be found in GitHub.

If anyone faces kind of this problem , upgrade to the latest ol3 version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.