Jump to a series of locations
Use the jumpTo function to showcase multiple locations.x
58
1
2
<html lang="en">
3
<head>
4
<meta charset="utf-8" />
5
<link rel="stylesheet" href="https://maps-sdk.trimblemaps.com/v4/trimblemaps-4.2.3.css" />
6
<script src="https://maps-sdk.trimblemaps.com/v4/trimblemaps-4.2.3.js"></script>
7
<style>
8
body { margin: 0; padding: 0; }
9
10
html,body,#map {
11
height: 100%;
12
}
13
#fly {
14
display: block;
15
position: absolute;
16
top: 20px;
17
left: 50%;
18
transform: translate(-50%);
19
width: 50%;
20
height: 40px;
21
padding: 10px;
22
border: none;
23
border-radius: 4px;
24
font-size: 12px;
25
text-align: center;
26
color: #fff;
27
background: #ee8a65;
28
}
29
</style>
30
</head>
31
<body>
32
<div id="map"></div>
33
<br>
34
<button type="button" id="fly">Fly</button>
35
<script>
36
TrimbleMaps.setAPIKey('YOUR_API_KEY_HERE');
37
const map = new TrimbleMaps.Map({
38
container: 'map',
39
style: TrimbleMaps.Common.Style.TRANSPORTATION,
40
center: [-74.5, 40],
41
zoom: 9,
42
});
43
44
document.getElementById('fly').addEventListener('click', () => {
45
// Fly to a random location by offsetting the point -74.50, 40
46
// by up to 5 degrees.
47
map.flyTo({
48
center: [
49
-74.5 + (Math.random() - 0.5) * 10,
50
40 + (Math.random() - 0.5) * 10,
51
],
52
essential: true, // this animation is considered essential with respect to prefers-reduced-motion
53
});
54
});
55
</script>
56
</body>
57
</html>
58