【问题标题】:Highlight country flag on blank world map when hovered on specific country悬停在特定国家/地区时,在空白世界地图上突出显示国旗
【发布时间】:2012-04-20 14:30:55
【问题描述】:

我正在使用jVectormap 插件在世界地图上突出显示国家/地区。现在正如我的问题所暗示的,我想在特定国家悬停时显示国家的国旗。

我不想为整个世界地图做图像映射。所以不要发布那个解决方案,我认为它不是一个可行的解决方案,因为我没有时间这样做。

如果有人使用任何插件、svg、谷歌地图、js 完成此功能,请帮助我。

如果有任何付费插件,我想知道。我已经搜索了2天。但是我还没有遇到过这样的功能。

【问题讨论】:

标签: map svg flags country jvectormap


【解决方案1】:

您可以为onRegionLabelShow 提供一个函数,该函数使用区域code 构造国家标志的URL,然后自定义label

$(function() {
    $('#map').vectorMap({
        onRegionLabelShow: function(event, label, code)
        {
           label.html(label.html()+
           '<br><img src="'+getFlagImgSrc(code)+'" height="20">');
        }
    });

    /*
    * Constructs a URL for a country flag image on Flags Of The World 
    * using the ISO-3166 Digraph 
    */
    function getFlagImgSrc(code)
    {
       return 'http://www.fotw.us/images/'+
               code.toLowerCase().substring(0,1)+
               '/'+
               code.toLowerCase()+
               '.gif';  
    }    

});​

当您将鼠标悬停在区域上时,呈现的标签与国家标志的外观示例:

【讨论】:

猜你喜欢
  • 2011-02-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-11-27
相关资源
最近更新 更多