4

Is there any way to get OpenLayers 3 to scale past the native zoom as is possible in Leaflet?

For reference, in Leaflet simply set maxZoom higher than maxNativeZoom and it stretches or perhaps scales the tile for a closer view.

In this example tiles go to 16. I'd like to scale 16 up to 18 for a closer view:

map = new ol.Map({
    target: 'map_div',
    renderer: 'canvas',
    view: new ol.View({
        center: ol.proj.transform([X_LO,X_LA], 'EPSG:4326', 'EPSG:3857'),
        zoom: 16,
        minZoom: 4,
        maxZoom: 16
        })
    });

L1=new ol.layer.Tile({
    source: new ol.source.XYZ({
        url:'http://blahblah.com/map_tiles.php?Z={z}&X={x}&Y={y}'
        }),
    maxResolution:152.87,// 9
    minResolution:1.94// 16
    });
map.addLayer(L1);

Solution from @erilem

map = new ol.Map({
    target: 'map_div',
    renderer: 'canvas',
    view: new ol.View({
        center: ol.proj.transform([X_LO,X_LA], 'EPSG:4326', 'EPSG:3857'),
        zoom: 16,
        minZoom: 4,
        maxZoom: 18
        })
    });

L1=new ol.layer.Tile({
    source: new ol.source.XYZ({
        url:'http://blahblah.com/map_tiles.php?Z={z}&X={x}&Y={y}',
        maxZoom: 16
        })
    });
map.addLayer(L1);

1 Answer 1

7

You just need to have more resolutions/zoom levels in your view than in your XYZ source.

By default the maxZoom for ol.source.XYZ is 42. You will want to set it to 16 in your case. You also want to remove maxResolution and minResolution from your layer, otherwise the layer won't be displayed when the view resolution is outside the [minResolution, maxResolution] range.

And you will need to set maxZoom to 18 in your view. So when the view will change to zoom level 17 and 18 tiles at zoom level 16 will be used.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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