With the map setup you’re ready to attach the tooltip to the markers and to define callbacks that define what happens when the tooltip is shown:

// Called right before tooltip is displayed
var before_show = function(marker, tooltip) {
// Set tooltip contents to the marker's title
tooltip.html(marker.title);
// NOTE you could also attach JSON objects to a marker and
// create more complex tooltips that save the world from evil politicians
tooltip.children('.thumbnail').attr('src', marker.product.thumbnail_url);
// NOTE you can also change the marker's icon
marker.setIcon('/images/hover.png');
};
// Called right before tooltip is hidden
var before_hide = function(marker, tooltip) {
marker.setIcon('/images/normal.png');
};
// Attach tooltip to the DIV element
var tooltip = new MapTooltip(map, $('#map-tooltip'), before_show, before_hide);
// Attach tooltip to marker, see http://code.google.com/intl/sv-SE/apis/maps/documentation/v3/reference.html#Marker
tooltip.addMarker(marker); // markers are usually loaded from a database