0

I have an old Opanlayers 2 application. And I need to convert an Opanlayers3 code to Opnelayers2, but could not.

Opanlaysrs 3 Code

  var epsg = "EPSG:900913";
  var projection = ol.proj.get(epsg);

  var projectionExtent = projection.getExtent();
  var size = ol.extent.getWidth(projectionExtent) / 256;
  var resolutions = [];
  var matrixIds = [];
  for (var z = 0; z < 28; z++) {        
    resolutions[z] = size / Math.pow(2, z);
    matrixIds[z] = epsg + ':'+ z;
  }

I will convet it to Opanlaysers 2 But could not:

  var epsg = "EPSG:900913";
  var projection = new Opanlayers.Projest(epsg);

  var projectionExtent = ???? // projection.getExtent();
  var size = ???? //ol.extent.getWidth(projectionExtent);
  var resolutions = [];
  var matrixIds = [];
  for (var z = 0; z < 28; z++) {        
    resolutions[z] = size / Math.pow(2, z);
    matrixIds[z] = epsg + ':'+ z;
  }

projection.getExtent(); is not a function

0

The OpenLayers 2 equivalent is:

  var epsg = "EPSG:900913";
  var projection = new Opanlayers.Projection(epsg);

  var projectionExtent = new OpenLayers.Bounds(OpenLayers.Projection.defaults["EPSG:900913"].maxExtent);
  var size = projectionExtent.getWidth() / 256;
  var resolutions = [];
  var matrixIds = [];
  for (var z = 0; z < 28; z++) {        
    resolutions[z] = size / Math.pow(2, z);
    matrixIds[z] = epsg + ':'+ z;
  }

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.