Highlight country flag on blank world map when hovered on specific country
Asked Answered
R

1

4

I'm using jVectormap plugin for country highlighting on world map. Now As my question suggests i want to show country's flag when specific country is hovered over.

I don't want to do image mapping for whole world map. so don't post that solution, i don't think its a feasible solution as i don't have such time to do that.

if anybody has done this functionality using any plugin, svg, google maps, js anything please help me out.

If any paid plugin is there even then i would like to know. I have searched for 2 days. But i haven't come across such functionality yet.

Ramey answered 7/4, 2012 at 7:6 Comment(1)
Possible duplicate of #9945765Occlusion
B
7

You can provide a function for onRegionLabelShow that uses the region code to construct a URL for the country flag and then customize the 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';  
    }    

});​

An example of how the rendered label looks with the country flag when you mouse over a region:

enter image description here

Bram answered 7/10, 2012 at 14:54 Comment(2)
Excuse me is it possible for you to look at this question too?#38672704Empyreal
The function onRegionLabelShow is renamed onRegionTipShow in v2.0+Aniseed

© 2022 - 2024 — McMap. All rights reserved.