Google MAP api V3 not shown into jQuery UI tab

This solution will work forever.
I've seen a lot of info about this problem, quite often very complicated and not working. The best solution is the easiest one: initializing the map only when it's to be shown.

In this example:

function mapInitialize() {
    var mapCanvas = document.getElementById('map-canvas');
    var mapOptions = {
      center: new google.maps.LatLng(44.5403, -78.5463),
      zoom: 8,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(mapCanvas, mapOptions);
  }
 
	$(function() {
		var mapOnce; //initialize map only once
		$("#tabs").tabs({
			show: function(e, ui) {
				if (ui.index == 3) {
					if(mapOnce!=true){
						//only once
						mapInitialize();
						mapOnce=true;
					}
				}
			}
		});
	});