<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div> 
<div>
<div>Thank for the answer, I found this project where some working examles includes using the same function, very useful:</div>

<div>https://github.com/soulslicer/NUS-Navigator</div>

<div> </div>

<div>Jo</div>

<div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="margin:0 0 10px 0;"><b>Gesendet:</b> Donnerstag, 11. Juli 2013 um 17:22 Uhr<br/>
<b>Von:</b> "Jürgen Dankoweit" <Juergen.Dankoweit@T-Online.de><br/>
<b>An:</b> "Jochen Wagner" <jj.wag@gmx.de><br/>
<b>Cc:</b> openlayers-users@lists.osgeo.org<br/>
<b>Betreff:</b> Re: [OpenLayers-Users] offline tiles</div>

<div name="quoted-content">Hi Jochen,<br/>
<br/>
<br/>
Am 11.07.2013 10:51, schrieb Jochen Wagner:<br/>
> Hi,<br/>
><br/>
> I try to use downloaded TMS tiles offline without a Server.<br/>
> My tiles are saved local on my Windows machine (no tileserver!):<br/>
> C:\inetpub\wwwroot\test\tiles\1.0.0\test1<br/>
> C:\inetpub\wwwroot is the root dir of my local webserver.<br/>
><br/>
> If I use folowing configuration the client shows the tiles fine (because the tiles come via http):<br/>
><br/>
> var test_xyz = new OpenLayers.Layer.TMS( "test_xyz",<br/>
> "http://localhost/test/tiles/",<br/>
> {<br/>
> layername: 'test1',<br/>
> type: "jpg",<br/>
> isBaseLayer:true,<br/>
> transitionEffect:'resize',<br/>
> resolutions:[529.16666666670005270134,396.87500000000000000000,264.58333333330000414207],<br/>
> units: projUnits,<br/>
> projection: mapProj,<br/>
> sphericalMercator: false<br/>
> }<br/>
> );<br/>
><br/>
> if I change the URL to the file it doesn't work.<br/>
><br/>
> var test_xyz = new OpenLayers.Layer.TMS( "test_xyz",<br/>
> "file:///C:/inetpub/wwwroot/test/tiles/",<br/>
> {<br/>
> layername: 'test1',<br/>
> type: "jpg",<br/>
> isBaseLayer:true,<br/>
> transitionEffect:'resize',<br/>
> resolutions:[529.16666666670005270134,396.87500000000000000000,264.58333333330000414207],<br/>
> units: projUnits,<br/>
> projection: mapProj,<br/>
> sphericalMercator: false<br/>
> }<br/>
> );<br/>
><br/>
> In Firebug I see that there comes no request.<br/>
> If I try to use a OpenLayers.Layer.XYZ Object I have the same problem.<br/>
> Later I want to use the tiles on an android device.<br/>
<br/>
I'm trying to create an application for my Nokia N900 that uses offline<br/>
maps too. I found the following solution:<br/>
<br/>
var tms = new OpenLayers.Layer.TMS( "TMS", "", {<br/>
type: 'png',<br/>
getURL: my_getTileURL, // <------------+<br/>
alpha: true, // |<br/>
isBaseLayer: true // |<br/>
}); // |<br/>
// |<br/>
function my_getTileURL(bounds) { // <---+<br/>
var res = this.map.getResolution();<br/>
var x = Math.round((bounds.left - this.maxExtent.left) / (res *<br/>
this.tileSize.w));<br/>
var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res *<br/>
this.tileSize.h));<br/>
var z = this.map.getZoom();<br/>
if (mapBounds.intersectsBounds( bounds ) && z >= mapMinZoom && z <=<br/>
mapMaxZoom ) {<br/>
console.log( this.url + z + "/" + x + "/" + y + "." + this.type);<br/>
return 'file:///<tiles_directory>/'+this.url + z + "/" + x + "/" + y +<br/>
"." + this.type;<br/>
} else {<br/>
return "empty_image.png";<br/>
}<br/>
}<br/>
<br/>
I hope this helps.<br/>
<br/>
Best regards<br/>
<br/>
Jürgen<br/>
<br/>
--<br/>
Meine stets unfertige Homepage: <a href="http://www.dankoweit.de" target="_blank">www.dankoweit.de</a></div>
</div>
</div>
</div></div></body></html>