Jump to a series of locations
Use the jumpTo function to showcase multiple locations.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Jump to a series of locations</title>
<meta property="og:description" content="Use the jumpTo function to showcase multiple locations." />
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<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>
<style>
body { margin: 0; padding: 0; }
html, body, #map { height: 100%; }
</style>
</head>
<body>
<div id="map"></div>
<script>
const cities = {
'type': 'FeatureCollection',
'features': [
{
'type': 'Feature',
'properties': {},
'geometry': {
'type': 'Point',
'coordinates': [105.757582,10.298233]
}
},
{
'type': 'Feature',
'properties': {},
'geometry': {
'type': 'Point',
'coordinates': [106.600446,8.695952]
}
},
{
'type': 'Feature',
'properties': {},
'geometry': {
'type': 'Point',
'coordinates': [108.319826,15.851182]
}
},
{
'type': 'Feature',
'properties': {},
'geometry': {
'type': 'Point',
'coordinates': [104.776057,18.961623]
}
},
{
'type': 'Feature',
'properties': {},
'geometry': {
'type': 'Point',
'coordinates': [107.008497,20.807664]
}
},
{
'type': 'Feature',
'properties': {},
'geometry': {
'type': 'Point',
'coordinates': [105.606298,21.507507]
}
}
]
};
const map = new trackasiagl.Map({
container: 'map',
style: 'https://maps.track-asia.com/styles/v1/streets.json?key=public_key',
center: {"lat":10.762622,"lng":106.660172},
zoom: 9
});
map.on('load', () => {
cities.features.forEach((city, index) => {
setTimeout(() => {
map.jumpTo({center: city.geometry.coordinates});
}, 2000 * index);
});
});
</script>
</body>
</html>