var heatmap = new google.maps.ImageMapType({ getTileUrl: function(coord, zoom) { var tileURL; $.get('getimage.php', { zoom: zoom, x: coord.x, y: coord.y }, function(data) { if(data.status) { tileURL=data.image; } }, "json"); return "tileURL"; }, tileSize: new google.maps.Size(256, 256), opacity:0.55, isPng: true });