// Themes begin am4core.useTheme(am4themes_animated); am4core.addLicense("CH261541974"); am4core.addLicense("MP386491625"); // Themes end var chart = am4core.create("chartdiv", am4maps.MapChart); // Set map definition for amn5 = mouseWheelBehavior: "none" chart.geodata = am4geodata_worldLow; chart.chartContainer.wheelable = false; // Set projection chart.projection = new am4maps.projections.Miller(); // Create map polygon series var polygonSeries = chart.series.push(new am4maps.MapPolygonSeries()); // Make map load polygon (like country names) data from GeoJSON polygonSeries.useGeodata = true; // Remove Antarctica polygonSeries.exclude = ["AQ"]; // Configure series var polygonTemplate = polygonSeries.mapPolygons.template; polygonTemplate.togglable = true; polygonTemplate.tooltipText = "{name} {period}"; polygonTemplate.fill = am4core.color("#395b74"); // color world polygonTemplate.stroke = am4core.color("#ffffff"); var lastSelected; polygonTemplate.strokeWidth = 0.5; //chart.dataSource.url = "/module/myData.php"; $.ajax( { url : "/module/myData.php", async : false, success: function (output) { polygonSeries.data=jQuery.parseJSON(output); }}); // polygonSeries.data = [{"id": "CN","name": "China", "fill": am4core.color("#187E6A")},{"id": "DOM","name": "Dominican Republic", "fill": am4core.color("#187E6A")},{"id": "EC","name": "Ecuador", "fill": am4core.color("#187E6A")},{"id": "GH","name": "Ghana", "fill": am4core.color("#187E6A")},{"id": "GD","name": "Grenada", "fill": am4core.color("#187E6A")},{"id": "MX","name": "Mexico", "fill": am4core.color("#187E6A")},{"id": "TN","name": "Tunisia", "fill": am4core.color("#187E6A")}]; polygonTemplate.events.on("hit-off", function(ev) { if (lastSelected) { // This line serves multiple purposes: // 1. Clicking a country twice actually de-activates, the line below // de-activates it in advance, so the toggle then re-activates, making it // appear as if it was never de-activated to begin with. // 2. Previously activated countries should be de-activated. lastSelected.isActive = false; } ev.target.series.chart.zoomToMapObject(ev.target); if (lastSelected !== ev.target) { lastSelected = ev.target; } var data = ev.target.dataItem.dataContext; if (data.icon) { var info = document.getElementById("info"); //info.innerHTML = "