-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathindex.html
145 lines (119 loc) · 3.66 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>Map Tour</title>
<link rel="stylesheet" href="https://js.arcgis.com/4.0/esri/css/main.css">
<style>
html, body, #viewDiv {
padding: 0;
margin: 0;
height: 100%;
}
#instructions {
float: right;
padding: 0.9em;
background-color: #DDD;
text-align: center;
border-radius: 5px;
z-index: 1000;
font-family: Sans-Serif;
pointer-events: none;
opacity: 0.6;
}
</style>
</head>
<body>
<div id="instructions">Loading…</div>
<div id="viewDiv"></div>
</body>
<script type="text/javascript">
var dojoConfig = {
packages: [{
name: "geotour",
location: 'https://esri.github.io/geotour-js/src/js'
}]
};
</script>
<script src="https://js.arcgis.com/4.0/"></script>
<script src="https://esri.github.io/geotour-js/util/js/esri-view-ui-visibility.js"></script>
<script type="text/javascript">
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/TileLayer",
"geotour/tour",
"esri/core/watchUtils",
"dojo/domReady!"
], function(Map, MapView, TileLayer, Tour, watchUtils) {
// Create the map.
var map = new Map({
basemap: {
baseLayers: [new TileLayer({
url: "https://services.arcgisonline.com/arcgis/rest/services/Canvas/World_Dark_Gray_Base/MapServer"
})]
}
});
// And the view.
var view = new MapView({
container: "viewDiv",
map: map,
center: [-100.68, 45.52], // lon, lat
zoom: 4
});
// Create a global - easier for debugging in the console.
mapView = view;
// Move the instructions DIV to the MapView UI.
view.ui.add(document.getElementById("instructions"), "top-right");
var tour = new Tour(view);
tour.watch("ready", function () {
// Zoom Map
view.goTo(tour.extent);
// Update the UI to say we're ready to animate.
document.getElementById("instructions").innerHTML = "Click the map to animate";
var clickEvent = view.on("click", handleClick);
function handleClick() {
// Disable the click event.
clickEvent.remove();
// Hide the UI and mouse
view.ui.hide();
// The tour will do this automatically, but we have a pause here and want to force the display to
// be cleared before the pause happens.
tour.clearDisplay();
// Delay the animation very slightly after clearing the UI
// This allows us to cut appropriately in Video Editing software if recording
// the animation... Likewise, delay re-adding the UI when done.
var tourAnimation = tour.animateWithDelay(750);
var cancelEvent = view.on("click", function () {
cancelEvent.remove();
tourAnimation.cancel();
restoreUI();
});
tourAnimation.then(function () {
// Pause slightly before redisplaying the UI.
window.setTimeout(function () {
cancelEvent.remove();
restoreUI();
}, 750);
}, function (err) {
// Don't show an error if we got here because the user cancelled the animation.
if (err.name !== "CancelError") {
console.log("Error during animation: " + err);
}
});
function restoreUI() {
view.ui.show();
clickEvent = view.on("click", handleClick);
}
}
});
tour.watch("loadError", function () {
// Update the UI to say we're ready to animate.
console.log("Tour error: " + tour.loadError);
alert("There was an error loading the tour!");
document.getElementById("instructions").innerHTML = "Oops. There was an error loading the tour.";
});
});
</script>
</html>