Jump to a series of locations
Use the jumpTo
function to showcase multiple locations.
<!DOCTYPE html><html><head><meta charset="utf-8" /><title>Jump to a series of locations</title><meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /><script src="https://unpkg.com/trackasia-gl@1.0.5/dist/trackasia-gl.js"></script><link href="https://unpkg.com/trackasia-gl@1.0.5/dist/trackasia-gl.css" rel="stylesheet" /><style> body { margin: 0; padding: 0; } #map { position: absolute; top: 0; bottom: 0; width: 100%; }</style></head><body><div id="map"></div>
<script>
var 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]
}
}
]
};
var 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', function () {
cities.features.forEach(function (city, index) {
setTimeout(function () {
map.jumpTo({ center: city.geometry.coordinates });
}, 2000 * index);
});
});
</script>
</body></html>