Solution 1 :

To answer your first question, (function(){ is an anonymous function. However, this is not part of your problem. These are not js files that you are going to modify. These are simply files that need to be linked to your page to make the whole chart essentially function.

ammap.js contains basic map functionality and the worldhigh.js contains a HighRes very detailed map of the entire world (so be careful with that one it is very heavy).

The code you are going to want to modify is going to look more like this:

  <!-- Styles -->
    #chartdiv {
      width: 100%;
      height: 500px;


    <!-- Resources -->
    <script src=""></script>
    <script src=""></script>
    <script src=""></script>
    <script src=""></script>
    <script src=""></script>

    <!-- Chart code -->
    am4core.ready(function() {

    // Themes begin
    // Themes end

    // Create map instance
    var chart = am4core.create("chartdiv", am4maps.MapChart);

    // Set map definition
    chart.geodata = am4geodata_worldLow;

    // Set projection
    chart.projection = new am4maps.projections.Miller();

    // Series for World map
    var worldSeries = chart.series.push(new am4maps.MapPolygonSeries());
    worldSeries.exclude = ["AQ"];
    worldSeries.useGeodata = true;

    var polygonTemplate = worldSeries.mapPolygons.template;
    polygonTemplate.tooltipText = "{name}";
    polygonTemplate.fill = chart.colors.getIndex(0);
    polygonTemplate.nonScalingStroke = true;

    // Hover state
    var hs = polygonTemplate.states.create("hover"); = am4core.color("#367B25");

    // Series for United States map
    var usaSeries = chart.series.push(new am4maps.MapPolygonSeries());
    usaSeries.geodata = am4geodata_usaLow;

    var usPolygonTemplate = usaSeries.mapPolygons.template;
    usPolygonTemplate.tooltipText = "{name}";
    usPolygonTemplate.fill = chart.colors.getIndex(1);
    usPolygonTemplate.nonScalingStroke = true;

    // Hover state
    var hs = usPolygonTemplate .states.create("hover"); = am4core.color("#367B25");

    }); // end am4core.ready()

    <!-- HTML -->
    <div id="chartdiv"></div>

This code was borrowed right from the amcharts demo site at

This is using a multiseries map. I am not sure which one you are using, but you will want to navigate to the demo of that map and then copy the demo code from the bottom. DONT WORRY ABOUT THE JS FILES. Just link those to your page and then copy the demo code. The map should work out of the box.

Problem :

My name is Minh Vuong Nguyen who is practicing duplicating AmChart’s interactive map. The error I am encountering is about the HTML code they provide in the link above.

After I have copy-pasted this link to my JavaScript, I have been looking at their JavaScript sourcecode, such as

<script src="" type="text/javascript"></script>
<script src="" type="text/javascript"></script>

Nonetheless, as I come to the “ammap.js” and “worldHigh.js” file, the code lines is very complicated because:

  1. A command like: (function)(){} is unknown to me, as you cannot use the bracket before announcing the function. Furthermore, some lines of code such as window.AmCharts?d=window.AmCharts:( is very complicated.
  2. The order from the source website itself is all over the place. I do not know how to organize it line-by-line like the normal JavaScript.
    var d;
        d.lang={},d.translations={},d.mapTranslations={},{},d.initHandlers=[],d.amString="am",d.pmString="pm");d.Class=function(a){var b=function(){arguments[0]!==d.inheriting&&({},this.construct.apply(this,arguments))};a.inherits?(b.prototype=new a.inherits(d.inheriting),b.base=a.inherits.prototype,delete a.inherits):(b.prototype.createEvents=function(){for(var a=0;a<arguments.length;a++)[arguments[a]]=[]},b.prototype.listenTo=function(a,b,c){this.removeListener(a,b,c);

Please kind me provide me with the appropriate approaches regarding this issue. I would love to thank you in advance.