1

Need to change the default zoom of OpenLayers 3 to do so adapted scales, type [1: 100000, 1: 50000.1: 25000.1: 10000.1: 1000.1: 500] have seen in Openlayers2 if you can, but at 3 I have not found a way to create it.

I tried to create a new projection, to create a new resolution, but no resolution to these scales are calculated.

The projection anyway not well created not because the coordinates of a town of Spain, are in the middle of Africa. I leave the code creating the projection.

 var etrs89 = new ol.proj.Projection({
     code: 'EPSG:25830',
     global:false,
     extent: [-729785.83,3715125.82,940929.67,9518470.69]
 });
var pucol=[729016.6720,4387551.5079]; 
var vista= new ol.View({
   projection: etrs89,
   center: pucol,
   resolutions: [65536, 32768, 16384, 8192, 4096, 2048,500,200,30,10], // TEST
   zoom: 0
 });
6

I have test it a bit and seems to work correct. Inspired from this

var res = getResolutionFromScale(200000);
alert(res);
function getResolutionFromScale(scale){
    var units = map.getView().getProjection().getUnits();
    var dpi = 25.4 / 0.28;
    var mpu = ol.proj.METERS_PER_UNIT[units];
    var resolution = scale/(mpu * 39.37 * dpi);
    return resolution;
}

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.