Hi there,
I have some simple code that goes off and loads a bunch of tiled images into a web page. What I am trying to do is replace one of the tiles with a blank image in the event the image does not exist on the server. I am using the Image() object onError event to do this, except, my test url function does not seem to be returning the hardcoded URL to my blank image. Any idea why not? Here is my code:
function get_my_url (bounds) {
//ignore all of this rubbish...
var res = this.map.getResolution();
var x = Math.round ((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
var y = Math.round ((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
var z = this.map.getZoom();
var path = z + "/" + y + "_" + x + "." + this.type;
var url = this.url;
if (url instanceof Array) {
url = this.selectUrl(path, url);
}
fullurl = url + path;
//here is the call to my image test function which should return my blank png URL
testImage(fullurl);
return fullurl;
}
function testImage(fullurl) {
var tester=new Image();
tester.src=fullurl;
tester.onerror = function (evt) {
fullurl="http://www.laudontech.com//temp//vladopenlayers//Z17/65536_65539.png"
return fullurl;
}
tester.onload = function (evt) {
alert(tester.src + " is loaded.");
}
}