GeoJSON areas

author(s): Torstein Hønsi

by Jernej Slejko

HTML

<script src="https://code.highcharts.com/maps/highmaps.js"></script>
<script src="https://code.highcharts.com/maps/modules/exporting.js"></script>
<script src="https://code.highcharts.com/maps/modules/offline-exporting.js"></script>

<div id="container"></div>

CSS

#container {
    height: 500px;
    min-width: 310px;
    max-width: 800px;
    margin: 0 auto;
}

.loading {
    margin-top: 10em;
    text-align: center;
    color: gray;
}

JavaScript

(async () => {


    const world = await fetch(
        'https://code.highcharts.com/mapdata/custom/world-highres3.topo.json'
    ).then(response => response.json());

    const uk = await fetch(
        'https://code.highcharts.com/mapdata/countries/gb/custom/gb-countries.topo.json'
    ).then(response => response.json());


    // Initialize the chart
    Highcharts.mapChart('container', {
        title: {
            text: 'Multiple map sources'
        },

        subtitle: {
            text: 'World and UK maps combined'
        },

        mapNavigation: {
            enabled: true,
            buttonOptions: {
                verticalAlign: 'bottom'
            }
        },

        plotOptions: {
            map: {
                showInLegend: false
            }
        },

        series: [{
            data: [['fo', 10], ['um', 11], ['us', 12], ['jp', 13], ['sc', 14], ['nz', 15],
        ['in', 16], ['kr', 17], ['fr', 18], ['fm', 19], ['cu', 20], ['cn', 21],
        ['pt', 22], ['sw', 23], ['sh', 24], ['br', 25], ['ec', 26], ['au', 27],
        ['ki', 28], ['ph', 29], ['mx', 30], ['es', 31], ['bu', 32], ['mv', 33],
        ['sp', 34], ['gr', 36], ['as', 37], ['dk', 38], ['gl', 39],
        ['gu', 40], ['mp', 41], ['pr', 42], ['vi', 43], ['ca', 44], ['st', 45],
        ['tz', 46], ['ar', 47], ['cv', 48], ['dm', 49], ['nl', 50], ['ye', 51],
        ['jm', 52], ['ws', 53], ['om', 54], ['vc', 55], ['tr', 56], ['bd', 57],
        ['sb', 58], ['lc', 59], ['nr', 60], ['no', 61], ['kn', 62], ['bh', 63],
        ['to', 64], ['fi', 65], ['id', 66], ['mu', 67], ['se', 68], ['tt', 69],
        ['my', 70], ['bs', 71], ['pw', 72], ['ir', 73], ['tv', 74], ['mh', 75],
        ['cl', 76], ['th', 77], ['gd', 78], ['ee', 79], ['ag', 80], ['tw', 81],
        ['bb', 82], ['it', 83], ['mt', 84], ['pg', 85], ['de', 86], ['vu', 87],
        ['gq', 88], ['cy', 89], ['km', 90], ['fj', 91], ['ru', 92], ['ug', 93],
        ['va', 94], ['sm', 95], ['kz', 96], ['az', 97], ['am',...