Unable to load raster from local file system

I am unable to load raster png maps from local file system. Below is the code:

this.osmLayer = new ol.layer.Tile({
visible: true,

source: new ol.source.OSM({

url: ‘./app/map/MY_CACHE/RasterMaps/{z}/{x}/{y}.png’

})

});

What could be the issue?

In continuation to above…

Although I am getting below messages on server console which is hosting my app:

GET /app/map/MY_CACHE/RasterMaps/7/35/55.png 200 16.473 ms - 100156

GET /app/map/MY_CACHE/RasterMaps/7/35/54.png 200 13.628 ms - 100156

GET /app/map/MY_CACHE/RasterMaps/7/34/53.png 200 26.784 ms - 100156

GET /app/map/MY_CACHE/RasterMaps/7/33/53.png 200 30.254 ms - 100156

GET /app/map/MY_CACHE/RasterMaps/7/35/53.png 200 24.355 ms - 100156

GET /app/map/MY_CACHE/RasterMaps/7/36/55.png 200 16.316 ms - 100156

GET /app/map/MY_CACHE/RasterMaps/7/36/54.png 200 21.835 ms - 100156

Still maps are not loaded

The code snippet you posted is insufficient to diagnose the problem.
What is your "ol" variable?
Are your OSM maps in WGS84 or a projected coords sys?
Try putting together enough of your code snippet to run the example in Sandcastle, and you may get some more useful suggestions from the cesium community

ol is openlayers instance: declare var ol: any;

Actually i can see OSM map when i write the below code:

this.osmLayer = new ol.layer.Tile({

visible: true,

source: new ol.source.OSM()

)};

But by this what is happening, the whole world map is getting loaded through online mode (i.e. requires internet).

Now, i want to load the whole world map through offline mode (i.e. .pngs saved in my hard drive).

For which i tried below code:

this.osmLayer = new ol.layer.Tile({
visible: true,

source: new ol.source.OSM({

url: ‘./app/map/MY_CACHE/RasterMaps/{z}/{x}/{y}.png’

})

});

But no success! I cant see any map.

Also, inside RasterMaps folder , there is an xml, the contents of which are below:

<?xml version="1.0" encoding="UTF-8"?>

RasterMaps

false

RasterMaps

MY_CACHE\RasterMaps

.png

image/png

image/dds

image/png

true

true

Do i need to edit this xml somewhere ?

nigamricha17-
That's a better explanation. What you are attempting is outside my limited expertise, maybe someone else can chime in here.
I think its not as simple as creating a file-based set of tiles. I suspect a webserver's HTML response to GET is not the same as opening a file on your harddrive? That would be cool if it was that simple to cache tiles. I'm interested in the solution, if you get it working. Good luck.

I can see maps using below code: But i am getting maps loaded at wrong location.

this.osmLayer = new ol.layer.Tile({
visible: true,

source: new ol.source.OSM({

url: ‘http://localhost:3005/resources/MY_CACHE/RasterMaps/{z}/{x}/{x}_{-y}.png’,

crossOrigin: null

})

})

Getting maps at wrong location since i think because my code does not read the root folder xml which has the origin, extents etc.

Please guide.