Hi again.
I think you need to abandon the old method - removing the overlay map
type and re-adding it to the map.
You will always get a flicker with that method i believe.
Try this for a basic overlay map:
[code]
function MyOverlayMap(tileSize) {
this.loadedTiles = {};
this.tileSize = tileSize;
}
MyOverlayMap.prototype.getTile = function (coord, zoom, ownerDocument)
{
function getURI(coord, zoom) {
return 'tile.php?x=' + coord.x + '&y=' + coord.y + '&z=' + zoom;
}
var tileUrl = getURI(coord, zoom);
var tileId = 'x_' + coord.x + '_y_' + coord.y + '_zoom_' + zoom;
var tile = ownerDocument.createElement('div');
tile.style.backgroundPosition = 'center center';
tile.style.backgroundRepeat = 'no-repeat';
tile.style.height = this.tileSize.height + 'px';
tile.style.width = this.tileSize.width + 'px';
tile.tileId = tileId; // do not use 'id' as new custom property as
it's a native property of all HTML elements
tile.tileURL = tileUrl;
this.tiles[tileId] = tile;
tileUrl += '×tamp=' + new Date().getTime();
var img = new Image();
img.onload = function () {
tile.style.backgroundImage = 'url(' + tileUrl + ')';
img.onload = null;
img = null;
};
img.src = tileUrl;
return tile;
};
MyOverlayMap.prototype.refreshTiles = function () {
for (var tile in this.tiles) {
var tileUrl = tile.tileUrl + '×tamp=' + new Date().getTime();
var img = new Image();
img.onload = function () {
tile.style.backgroundImage = 'url(' + tileUrl + ')';
img.onload = null;
img = null;
};
img.src = tileUrl;
}
};
MyOverlayMap.prototype.releaseTile = function (tile) {
delete this.tiles[tile.tileId];
tile = null;
};
[/code]
You can get a better formatted copy of the code here:
http://code.martinpearman.co.uk/deleteme/MyOverlayMap.js
I've removed all opacity code and left just the basic stuff.
So you create an instance of the overlay map type, add it to your
map's overlayMapTypes and refresh it every 5 seconds:
[code]
var my myOverlayMap=new MyOverlayMap(new google.maps.Size(256, 256));
myMap.overlayMapTypes.insertAt(0, myOverlayMap);
setInterval(function(){
myOverlayMap.refreshTiles();
};, 5000);
[/code]
I'd be keen to see it working if you get that far?
Martin.