2013-09-07 2 views
0

나는 각 국가의 기본 레이블에 각 국가 이름을 표시 할 때 현재 jvector 맵을 사용 중입니다. 그러나 나는 대륙 선택 (World Map)에 따라 지역을 선택하고 싶다. 예를 들어jvectormap에서지도 대륙을 현명하게 표시/표시하는 방법

: 기본적으로

세계지도,

내가 대신 국가의 국가 (미국, 캐나다, 멕시코, 브라질, 볼리비아 등)의 표시 국가 이름을 가져

이름 미국으로 라벨을 표시하고 전체 미국 지역을 강조 표시해야합니다.

동일한 시나리오에서 EUROPE, 아시아 대륙도 있습니다.

친절하게 도와주세요.

미리 감사드립니다.

답변

0

var data = { 
    "countries" : [ 
       { 
       "name" : "Brazil", 
       "code" : "BR", 
       "pGdp" : "6938", 
       "cGdp" : "1313590", 
       "pop" : "196342587", 
       "continent" : "America" 
       }, 
       { 
       "name" : "United States", 
       "code" : "US", 
       "pGdp" : "45845", 
       "cGdp" : "13843825", 
       "pop" : "303824646", 
       "continent" : "America" 
       } 
       ] 
} 

var countryData = []; 

jQuery.each(data.countries, function() { 
    countryData[this.code] = this[.pGdp]; 
}); 

JVM의 설정을 시도 ...

series : { 
    regions : [ { 
     values : countryData, 
     scale : [ '#C8EEFF', '#0071A4' ], 
     normalizeFunction : 'polynomial' 
    } ] 
}, 
onRegionLabelShow: function(e, el, code) { 
    //search through data to find the selected country by it's code 
    var country = $.grep(data.countries, function(obj, index) { 
    return obj.code == code; 
    })[0]; //snag the first one 
    if (country != undefined) { 
     el.html(el.html() + "<br/><b>Code: </b>" +country.code + "<br/><b>Continent : </b> " + country.continent); 
    } 
}