最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Showing Countrystate data in jVectorMap - Stack Overflow

programmeradmin4浏览0评论

I must admit that I am new to jQuery and JS but I really like the cool things you can do with jVectorMap. But so far I failed to add one thing: On mouseover/hover normally the name of the state or country is shown. Is it possible to add the related data (e.g. the GDP value)? And / or is it possible to add a legend with the color values of the countries/states? Thanks a lot! Claus

I must admit that I am new to jQuery and JS but I really like the cool things you can do with jVectorMap. But so far I failed to add one thing: On mouseover/hover normally the name of the state or country is shown. Is it possible to add the related data (e.g. the GDP value)? And / or is it possible to add a legend with the color values of the countries/states? Thanks a lot! Claus

Share Improve this question edited Mar 29, 2012 at 14:34 fglez 8,5524 gold badges50 silver badges78 bronze badges asked Nov 21, 2011 at 8:54 der.hamburgerder.hamburger 131 silver badge3 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

Using the data visualization example you could add in a callback function to show the related figure for the chosen state code. So if your data looked like:

var gdpData = {"ca":34.56 ...}

Then you could do something like...

$('#map').vectorMap({
    colors: colors,
    hoverOpacity: 0.7,
    hoverColor: false,
    onLabelShow: function(event, label, code){
       label.text(label.text() + " (" + gdpData[code] + ")");
    }
});
发布评论

评论列表(0)

  1. 暂无评论