【发布时间】:2019-02-19 19:51:24
【问题描述】:
我在 AmCharts 4 地图上开始了一个新项目。首先我选择一个大陆,然后我选择一个国家。
如何获取 iso_code 点击的国家/地区?
是否可以隐藏其他国家并仅在地图上显示选定的国家/地区?
我的代码:
// Countries
var countriesSeries = chart.series.push(new am4maps.MapPolygonSeries());
var countries = countriesSeries.mapPolygons;
countriesSeries.visible = false; // start off as hidden
countriesSeries.exclude = ["AQ"];
countriesSeries.geodata = am4geodata_worldLow;
countriesSeries.useGeodata = true;
// Hide each country so we can fade them in
countriesSeries.events.once("inited", function(){
hideCountries();
});
var countryTemplate = countries.template;
countryTemplate.applyOnClones = true;
countryTemplate.fill = am4core.color("#a791b4");
countryTemplate.fillOpacity = 0.3;
countryTemplate.strokeOpacity = 0.3;
countryTemplate.tooltipText = "{name}";
countryTemplate.events.on("hit", function(event){
chart.zoomToMapObject(event.target);
// how can i get iso_code clicked country ?
// and hide other countries
showPoints(); // function show point on selected country
});
【问题讨论】:
标签: javascript amcharts