1st modification of getTileUrl

This commit is contained in:
andygup 2014-02-21 17:25:07 -07:00
parent f3ab0f06b9
commit 073ec191af

View File

@ -64,49 +64,55 @@ define([
*/
layer.getTileUrl = function(level,row,col)
{
console.log("looking for tile",level,row,col);
var url = this._getTileUrl(level,row,col);
if(isNaN(level) && isNaN(row) && isNaN(col)){
console.log("looking for tile",level,row,col);
var url = this._getTileUrl(level,row,col);
if( this.offline.online )
{
console.log("fetching url online: ", url);
layer._lastTileUrl = url;
return url;
if( this.offline.online )
{
console.log("fetching url online: ", url);
layer._lastTileUrl = url;
return url;
}
url = url.split('?')[0];
/* temporary URL returned immediately, as we haven't retrieved the image from the indexeddb yet */
var tileid = "void:"+level+"-"+row+"-"+col;
this.offline.store.get(url, function(success, offlineTile)
{
/* when the .get() callback is called we replace the temporary URL originally returned by the data:image url */
var img = query("img[src="+tileid+"]")[0];
if( success )
{
console.log("found tile offline", url);
var imgURL = "data:image;base64," + offlineTile.img;
// search for the img with src="void:"+level+"-"+row+"-"+col and replace with actual url
img.style.borderColor = "blue";
// when we return a nonexistent url to the image, the TiledMapServiceLayer::_tileErrorHandler() method
// sets img visibility to 'hidden', so we need to show the image back once we have put the data:image
img.style.visibility = "visible";
img.src = imgURL;
return ""; /* this result goes nowhere, seriously */
}
else
{
img.style.borderColor = "green";
console.log("tile is not in the offline store", url);
return ""; /* this result goes nowhere, seriously */
}
});
return tileid;
}
else{
return null;
}
url = url.split('?')[0];
/* temporary URL returned immediately, as we haven't retrieved the image from the indexeddb yet */
var tileid = "void:"+level+"-"+row+"-"+col;
this.offline.store.get(url, function(success, offlineTile)
{
/* when the .get() callback is called we replace the temporary URL originally returned by the data:image url */
var img = query("img[src="+tileid+"]")[0];
if( success )
{
console.log("found tile offline", url);
var imgURL = "data:image;base64," + offlineTile.img;
// search for the img with src="void:"+level+"-"+row+"-"+col and replace with actual url
img.style.borderColor = "blue";
// when we return a nonexistent url to the image, the TiledMapServiceLayer::_tileErrorHandler() method
// sets img visibility to 'hidden', so we need to show the image back once we have put the data:image
img.style.visibility = "visible";
img.src = imgURL;
return ""; /* this result goes nowhere, seriously */
}
else
{
img.style.borderColor = "green";
console.log("tile is not in the offline store", url);
return ""; /* this result goes nowhere, seriously */
}
});
return tileid;
};
/**