﻿
var MapTooltip = function(id, className)
{
   this.id        = id;
   this.className = className;
   this.offsetX   = -14;
   this.offsetY   = 17;
   this.anchorX = "left";
   this.anchorY = "top";
}

MapTooltip.prototype = new GOverlay();

MapTooltip.prototype.initialize = function(gmap)
{
   this.gmap = gmap;
   this.div = document.getElementById(this.id);

   if (!this.div)
   {
      this.div = document.createElement("div");
      this.div.setAttribute("id", this.id);
      this.div.className = this.className;
      this.div.style.position = "absolute";
      this.div.style.zIndex = "1000";
      gmap.getPane(G_MAP_FLOAT_PANE).appendChild(this.div);
   }
}

MapTooltip.prototype.remove = function()
{
   if (this.div != null)
   {
      this.div.parentNode.removeChild(this.div);
   }
}

MapTooltip.prototype.redraw = function(force)
{
   // Not implemented
}

MapTooltip.prototype.setHtml = function(html)
{
   if (this.div != null)
   {
      $("#" + this.id).html(html);
   }
}

MapTooltip.prototype.setLocation = function(latlng)
{
   var pixelPosX = (this.gmap.fromLatLngToDivPixel(latlng)).x;
   var pixelPosY = (this.gmap.fromLatLngToDivPixel(latlng)).y;

   this.setLocationPixel(pixelPosX, pixelPosY);
}

MapTooltip.prototype.setLocationPixel = function(pixelPosX, pixelPosY)
{
   $("#" + this.id).css(this.anchorX, (pixelPosX - this.offsetX) + "px");
   $("#" + this.id).css(this.anchorY, (pixelPosY - this.offsetY) + "px");
}
