javascriptamchartsammap

To start using amMaps


I tried to use amMaps library to create a map. Here is my code:

<body>
    <div id="chardiv"></div>

    <script src="https://www.amcharts.com/lib/4/core.js"></script>
    <script src="https://www.amcharts.com/lib/4/maps.js"></script>
    <script src="https://www.amcharts.com/lib/4/geodata/worldLow.js"></script>
    <script>
        var map = am4core.create("chardiv", am4maps.MapChart);
        map.geodata = am4geodata_worldLow;
    </script>
</body>

As result I got a transparent div-block with amCharts logo. What did I do wrong?


Solution

  • If you change your script part

    am4core.ready(function() {
    var chart = am4core.create("chartdiv", am4maps.MapChart);
    chart.geodata = am4geodata_worldLow;
    
    var worldSeries = chart.series.push(new am4maps.MapPolygonSeries());
    worldSeries.exclude = ["AQ"];
    worldSeries.useGeodata = true;
    }); 
    

    It should work