﻿// 20/03/2008  Put labels on the map
// 20/03/2008  Unit Test Complete

function GLabel(point, text, color) {
    this.lblPoint = point;
    this.lblText = text;
    this.lblColor = color;
} 
  
GLabel.prototype.initialize = function(map) {
    var scrLabel = document.createElement("div");
    scrLabel.style.position = "absolute";
    scrLabel.style.color = this.lblColor;
    scrLabel.style.fontSize = "12px";
    // Label gets printed 4 times in black, once in normal to give an outine
    scrLabel.innerHTML = '<div style="position:absolute;left:-1px;top:0px;color=#000000"><b>'+this.lblText+'</b></div>'
                       +  '<div style="position:absolute;left:+1px;top:0px;color=#000000"><b>'+this.lblText+'</b></div>'
                       +  '<div style="position:absolute;left:0px;top:-1px;color=#000000"><b>'+this.lblText+'</b></div>'
                       +  '<div style="position:absolute;left:0px;top:+1px;color=#000000"><b>'+this.lblText+'</b></div>'
                       +  '<div style="position:absolute;left:0px;top:0px;"><b>'+this.lblText+'</b></div>';

//    scrLabel.style.backgroundColor = this.lblColor;
//    scrLabel.style.border = "2";
//    scrLabel.style.borderStyle = "ridge";
//    scrLabel.style.paddingLeft = "1";
//    scrLabel.style.paddingRight = "1";
//    scrLabel.style.fontSize = "10px";
    map.getPane(G_MAP_FLOAT_SHADOW_PANE).appendChild(scrLabel);
    this.map_ = map;
    this.div_ = scrLabel;
}

GLabel.prototype.redraw = function(force) {
    var scrPos = this.map_.fromLatLngToDivPixel(this.lblPoint);
    this.div_.style.left = (scrPos.x - 10) + "px";
    this.div_.style.top = (scrPos.y - 5) + "px";
}

GLabel.prototype.remove = function() { 
    this.div_.parentNode.removeChild(this.div_);
}