2014-04-30 49 views
1

如何在jqvmap中的「onRegionOver:function(event,code,region)」中獲取鼠標位置?JQVMap Event(Mouse Position)

函數中的事件對象沒有鼠標位置的屬性。 當鼠標滑過該區域時,我需要顯示帶有額外國家/地區信息的div。

非常感謝你!

回答

2

首先我不確定這是否正確。如果你打開jquery.vmap.js插件文件,看看這個代碼:

if (e.type == 'mouseover') { 
    jQuery(params.container).trigger(regionMouseOverEvent, [code, mapData.pathes[code].name]); 

更改以下行的代碼:

jQuery(params.container).trigger(regionMouseOverEvent, [e, code, mapData.pathes[code].name]); 

此事件e作爲參數在插件傳遞給函數。而在你的回調函數添加一個參數

onRegionOver:function(event,e,code,region){ 
    alert(e.pageX,"_",e.pageY); 
} 

這個工作對我來說...希望這可以幫助你