" + this.detailWinHTML + "<\/td> | <\/a><\/td><\/tr><\/table>";
html = " " + html + " ";
this.detailOpen = true;
if (!this.tooltipText)
{
this.ttWidth = 150;
this.ttHeight = 30;
setTTPosition(this); // compute ttTop, ttLeft
}
initDetailWin(this, this.ttTop, this.ttLeft, html);
PdMarkerAddToExtList(this);
}
PdMarker.prototype.closeDetailWin = function() {
this.detailOpen = false;
if (this.detailObject)
{
this.setMouseOutEnabled(true);
this.onMouseOut();
// GEvent.trigger(this, "mouseout");
this.map.getPane(G_MAP_FLOAT_PANE).removeChild(this.detailObject);
this.detailObject = null;
}
}
PdMarker.prototype.deleteObjects = function() {
if (this.tooltipObject)
{
this.map.getPane(G_MAP_FLOAT_PANE).removeChild(this.tooltipObject);
this.tooltipObject = null;
}
if (this.detailObject)
{
this.map.getPane(G_MAP_FLOAT_PANE).removeChild(this.detailObject);
this.detailObject = null;
}
}
PdMarker.prototype.remove = function(a) {
removeMarkerFromMapList(this.map, this);
PdMarkerRemoveFromExtList(this.getId());
GMarker.prototype.remove.call(this);
this.deleteObjects();
}
PdMarker.prototype.setOpacity = function(b) {
if (b < 0)
b=0;
if (b >= 100)
b=100;
var c = b / 100;
this.percentOpacity = b;
var d = document.getElementById(this.objId);
if (d)
{
if(typeof(d.style.filter)=='string'){d.style.filter='alpha(opacity:'+b+')';}
if(typeof(d.style.KHTMLOpacity)=='string'){d.style.KHTMLOpacity=c;}
if(typeof(d.style.MozOpacity)=='string'){d.style.MozOpacity=c;}
if(typeof(d.style.opacity)=='string'){d.style.opacity=c;}
}
}
PdMarker.prototype.setOpacityNew = function(b) {
setObjOpacity(this.objId);
this.percentOpacity = b;
}
// ***** Private routines *****
function setObjOpacity(objId, b) {
if (b < 0)
b=0;
if (b >= 100)
b=100;
var c = b / 100;
var d = document.getElementById(objId);
if (d)
{
if(typeof(d.style.filter)=='string'){d.style.filter='alpha(opacity:'+b+')';}
if(typeof(d.style.KHTMLOpacity)=='string'){d.style.KHTMLOpacity=c;}
if(typeof(d.style.MozOpacity)=='string'){d.style.MozOpacity=c;}
if(typeof(d.style.opacity)=='string'){d.style.opacity=c;}
}
}
function idToElemId(id) {
return "ttobj" + id;
}
function initTooltip(theObj) {
theObj.objId = idToElemId(theObj.internalId);
theObj.anchorLatLng = theObj.point;
var b = document.createElement('span');
theObj.tooltipObject = b;
b.setAttribute('id',theObj.objId);
b.innerHTML = theObj.tooltipText;
// append to body for size calculations
var c = document.body;
var d = document.getElementById("pdmarkerwork");
if (d)
c = d;
c.appendChild(b);
b.style.position = "absolute";
b.style.bottom = "5px";
b.style.left = "5px";
b.style.zIndex = 1;
if (theObj.percentOpacity)
theObj.setOpacity(theObj.percentOpacity);
var tempObj = document.getElementById(theObj.objId);
theObj.ttWidth = tempObj.offsetWidth;
theObj.ttHeight = tempObj.offsetHeight;
c.removeChild(b);
b.style.zIndex = 600000;
b.style.bottom = "";
b.style.left = "";
// theObj.map.div.appendChild(b);
theObj.map.getPane(G_MAP_FLOAT_PANE).appendChild(b);
}
function initDetailWin(theObj, top, left, html) {
theObj.detailId = "detail" + theObj.internalId;
var b = document.createElement('span');
theObj.detailObject = b;
b.setAttribute('id',theObj.detailId);
b.innerHTML = html;
b.style.display = "block";
b.style.position = "absolute";
b.style.top = top + "px";
b.style.left = left + "px";
b.style.zIndex = 600001;
map = theObj.map;
map.getPane(G_MAP_FLOAT_PANE).appendChild(b);
}
function setTTPosition(theObj) {
var gap = 5;
var map = theObj.map;
var pt = theObj.getPoint();
var ttPos = latLongToPixel(map, pt, map.getZoom());
var theIcon = theObj.getIcon();
// ttPos.x += Math.floor(theIcon.iconAnchor.x/2);
ttPos.y -= Math.floor(theIcon.iconAnchor.y/2);
var rightSide = true;
var bounds = map.getBounds();
var boundsSpan = bounds.toSpan();
var longSpan = boundsSpan.lng();
var mapWidth = map.getSize().width;
var tooltipWidthInDeg = (theObj.ttWidth + theIcon.iconSize.width + 6) / mapWidth * longSpan;
if (pt.lng() + tooltipWidthInDeg > bounds.getNorthEast().lng() && permitLeft)
rightSide = false;
if (rightSide)
{
ttPos.y -= Math.floor(theObj.ttHeight/2);
ttPos.x += (theIcon.iconSize.width - theIcon.iconAnchor.x) + gap;
}
else
{
ttPos.y -= Math.floor(theObj.ttHeight/2);
ttPos.x -= (theIcon.iconAnchor.x + theObj.ttWidth) + gap;
}
theObj.ttLeft = ttPos.x;
theObj.ttTop = ttPos.y;
if (theObj.tooltipObject)
{
theObj.tooltipObject.style.left = ttPos.x + "px";
theObj.tooltipObject.style.top = ttPos.y + "px";
}
}
function makeInterface(a) {
var b = a || window;
b.PdMarker = PdMarker;
}
makeInterface();
}
PdMarkerNamespace();
|