2013-03-05 120 views

回答

0

的一种方法是创建一个MapToolTip

我制成一个围绕跟随鼠标在偏离设定位置。基本上它是一个绝对位置风格的div,在mousemove上更新。

tooltip

我的代码:

var MyAPP = MyAPP || {}; 

MyAPP.MapToolTip = function (position, text) { 

    var content = '<div id="tool_tip" class="dropSheet ui-corner-all"><span id="info_window_text">' + text + '</span></div>'; 

    var toolTip = $(content).hide().appendTo('div#wrapper div#content_wrapper'); 
    toolTip.IsVisible = false; 

    var mouseMove = function (e) { 

     if (toolTip.IsVisible) { 
      toolTip.fadeIn() 
     } 
     toolTip.css('top', e.clientY + 30); 
     toolTip.css('left', e.clientX + 30); 
     toolTip.IsVisible = true; 
    }; 

    this.Destroy = function() { 
     MyAPP.UI.Map.getMap().events.unregister("mousemove", MyAPP.UI.Map.getMap(), mouseMove); 
     toolTip.IsVisible = null; 
     toolTip.fadeOut(); 
     toolTip.remove(); 
     content = null; 
     toolTip = null; 
     mouseMove = null; 
    }; 

    MyAPP.UI.Map.getMap().events.register("mousemove", MyAPP.UI.Map.getMap(), mouseMove); 

    return; 

}; 
.dropSheet { 
    background-color: #000000; 
    background-image: none; 
    opacity: 0.6; 
} 
div#info_window { 
    color: White; 
    font-family: Verdana,Arial; 
    font-size: 0.6em; 
    left: 490px; 
    padding: 6px; 
    position: absolute; 
    top: 100px; 
    width: 220px; 
    z-index: 99; 
}