[GIS] How to display GeoWebCache local tiles with OpenLayers 3

geoserveropenlayers

I've created local tiles using GeoWebCache and they are inside local folder names :

Layer - EPSG_4326_9-
- 19_10 -
- 0608_0339.png
- 0608_0340.png
- EPSG_4326_10 -
-19_10 -
-1217_0679.png
-1217_0680.png
- EPSG_4326_11 -
-38_21
-2435_1358.png
-2435_1359.png

How can I show them using OL ?
I thought using XYZ layer , something like :

var test =  new ol.layer.Tile({
title: 'test',
type: 'base',
visible: true,
source: new ol.source.XYZ({
    tileUrlFunction: function (coordinate) {
        if (coordinate == null) {
            return "";
        }
        var z = coordinate[0];
        var x = coordinate[1];
        var y = coordinate[2];
        //var y = (1 << z) - coordinate[2] - 1;

        return 'tiles/layer/EPSG_4236_' + z + '/' + x + '/' + y + '.png';
    }
})

});

but the Z X Y numbers don't match ….

Best Answer

There is an outstanding pull request which should give you a good idea on how to achieve this: https://github.com/openlayers/ol3/pull/3241/files

Related Question