Skip to content

Sync movement of multiple maps

Synchronize TrackAsia GL JS maps with the sync-move plugin.

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Sync movement of multiple maps</title>
    <meta property="og:description" content="Synchronize TrackAsia GL JS maps with the sync-move plugin." />
    <meta charset='utf-8'>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel='stylesheet' href='https://unpkg.com/[email protected]/dist/trackasia-gl.css' />
    <script src='https://unpkg.com/[email protected]/dist/trackasia-gl.js'></script>
    <script src="https://unpkg.com/@mapbox/[email protected]"></script>

    <style>
        body { margin: 0; padding: 0; }
        html, body { height: 100%; }
        #map1, #map2, #map3 { height: 100%; width: 100%; }
        .maps {
            display: flex;
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body>
    <div class="maps">
    <div id="map1"></div>
    <div id="map2"></div>
    <div id="map3"></div>
    </div>
<script>
    const map1 = new trackasiagl.Map({
        container: 'map1',
        style: 'https://static.track-asia.com/demotiles/style.json',
        center: [0, 0],
        zoom: 1,
        trackasiaLogo: true
    });
    const map2 = new trackasiagl.Map({
        container: 'map2',
        style: 'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json',
        center: [0, 0],
        zoom: 1,
        trackasiaLogo: true
    });
    const map3 = new trackasiagl.Map({
        container: 'map3',
        style: 'https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json',
        center: [0, 0],
        zoom: 1,
        trackasiaLogo: true
    });

    syncMaps(map1, map2, map3);
</script>
</body>
</html>