2013-02-15 32 views
5
var setMap = function (name) { 
     var data = { 
      map: 'world_en', 
      backgroundColor: null, 
      borderColor: '#333333', 
      borderOpacity: 0.5, 
      borderWidth: 1, 
      color: '#c6c6c6', 
      enableZoom: true, 
      hoverColor: '#c9dfaf', 
      hoverOpacity: null, 
      values: sample_data, 
      normalizeFunction: 'linear', 
      scaleColors: ['#b6da93', '#909cae'], 
      selectedColor: '#c9dfaf', 
      selectedRegion: null, 
      showTooltip: true, 
      onLabelShow: function (event, label, code) { 

      }, 
      onRegionOver: function (event, code) { 
       if (code == 'ca') { 
        event.preventDefault(); 
       } 
      }, 
      onRegionClick: function (element, code, region) { 
       var message = 'You clicked "' + region + '" which has the code: ' + code.toUpperCase(); 
       alert(message); 
      } 
     }; 

     data.map = name + '_en'; 
     var map = jQuery('#vmap_' + name); 
     map.width(map.parent().parent().width()); 
     map.show(); 
     map.vectorMap(data); 
     map.hide(); 
    } 

任何人都知道如何使用onRegionClick函數中點擊區域的值?我使用此地圖提供網站統計信息,並希望在點擊時發出類似於「美國(美國)的1000次視圖」的提示。JQVMap - 如何顯示數據值onregionclick

+0

已經算出來了......無論如何;) – lexith 2013-02-15 14:37:03

+0

它是什麼?解決方案 ? :) – Rad 2013-04-09 21:43:14

+0

我剛剛發佈我的答案。希望能幫助到你。 – lexith 2013-04-10 23:45:10

回答

7

正如我在我的評論中所說的,我在問了問題後發現瞭解決方案,但對於那些有這個小問題的人,我也只是發佈我的解決方案。 您只需將要顯示的字符串追加到標籤。

onLabelShow: function (event, label, code) { 
    if(sample_data[code] > 0) 
     label.append(': '+sample_data[code]+' Views'); 
} 

希望它有幫助。

+0

謝謝aeres它有幫助 – Rad 2013-04-12 00:35:21