2012-12-15 26 views
3

我想在地圖中設置區域,而不禁用點擊數據。有沒有辦法做到這一點...我已經成功地禁用了顏色變化onRegionOver,但相同的區域仍然響應點擊(並更改區域的顏色...)。 我試圖從onRegionOver和onRegionClick事件調用preventDefault()方法...但它沒有幫助... 希望得到任何幫助。JQVMap - 將區域設置爲禁用/不可選

謝謝!

回答

3

遲到的迴應,但也許這可以幫助下一個人。

var states = 'ca,co,tx,ny,ks,mo';   
$('#vmap').vectorMap({ 
map: 'usa_en', 
    selectedRegion: 'tx', 
    backgroundColor: '#ffffff', 
    color: '#E6E7E9', 
    hoverColor: '#03235E', 
    enableZoom: false, 
    showTooltip: true, 
    onRegionOver: function (event, code, region) { 
    // if it's not in the approved list, do nothing, 
    // else allow normal behavior 
    if (states.toLowerCase().indexOf(code) <= -1) { 
     event.preventDefault(); 
    } 
    }, 
    onRegionClick: function (event, code, region) { 
    // if it's not in the approved list, do nothing, else handle it 
    if (states.toLowerCase().indexOf(code) <= -1) { 
     event.preventDefault(); 
    } 
    else { 
     //handle state click 
    } 
    } 
}) 
+2

在1.5.0版本,你可能需要 '返回false;',而不是'event.preventDefault();''在onRegionClick' –