forked from rhiever/optimal-roadtrip-usa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcanada-trip-landmarks.html
121 lines (109 loc) · 4.99 KB
/
canada-trip-landmarks.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="description" content="Randy Olson uses machine learning to find the optimal road trip across Canada.">
<meta name="author" content="Randal S. Olson">
<title>An optimal road trip across Canada according to machine learning</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
#panel {
position: absolute;
top: 5px;
left: 50%;
margin-left: -180px;
z-index: 5;
background-color: #fff;
padding: 10px;
border: 1px solid #999;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
<script>
var directionsDisplay1, directionsDisplay2;
var directionsDisplay3;
var marker;
var markerOptions = {icon: "http://maps.gstatic.com/mapfiles/markers2/marker.png"};
var directionsDisplayOptions = {preserveViewport: true,
markerOptions: markerOptions};
var directionsService = new google.maps.DirectionsService();
var map;
function initialize() {
var center = new google.maps.LatLng(57, -95);
var mapOptions = {
zoom: 4,
center: center
};
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
directionsDisplay1.setMap(map);
directionsDisplay2.setMap(map);
directionsDisplay3.setMap(map);
marker.setMap(map);
}
function calcRoute(start, end, routes) {
switch (start) {
case "Signal Hill National Historic Site, St. John's, NL, Canada":
directionsDisplay1 = new google.maps.DirectionsRenderer(directionsDisplayOptions);
break;
case "Old Montreal, Montreal, QC, Canada":
directionsDisplay2 = new google.maps.DirectionsRenderer(directionsDisplayOptions);
break;
case "Jasper National Park, Jasper, AB T0E 1E0, Canada":
directionsDisplay3 = new google.maps.DirectionsRenderer(directionsDisplayOptions);
break;
}
var waypts = [];
for (var i = 0; i < routes.length; i++) {
waypts.push({
location:routes[i],
stopover:true});
}
var request = {
origin: start,
destination: end,
waypoints: waypts,
optimizeWaypoints: false,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
switch (start) {
case "Signal Hill National Historic Site, St. John's, NL, Canada":
directionsDisplay1.setDirections(response);
break;
case "Old Montreal, Montreal, QC, Canada":
directionsDisplay2.setDirections(response);
break;
case "Jasper National Park, Jasper, AB T0E 1E0, Canada":
directionsDisplay3.setDirections(response);
break;
}
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
calcRoute("Signal Hill National Historic Site, St. John's, NL, Canada", "Old Montreal, Montreal, QC, Canada", ["Gros Morne National Park, Norris Point, NL A0K 3V0, Canada", "Cabot Trail, Pleasant Bay, NS B0E 2P0, Canada", "Peggys Cove, NS, Canada", "Province House National Hist, 165 Richmond Street, Charlottetown, PE C1A 1J1, Canada", "Green Gables, 8619 Cavendish Road, Cavendish, PE C0A 1M0, Canada", "Hopewell Rocks Ocean Tidal, Discovery Road, Hopewell Cape, NB E4H 4Z5, Canada", "Parc National de l'Île-Bonaventure-et-du-Rocher-Percé, 4 Rue du Quai, Percé, QC G0C 2L0, Canada", "Hartland Bridge, Hartland Covered Bridge, Hartland, E7P, Canada"]);
calcRoute("Old Montreal, Montreal, QC, Canada", "Jasper National Park, Jasper, AB T0E 1E0, Canada", ["Parliament Buildings, Ottawa, ON, Canada", "Niagara Falls, ON, Canada", "Pukaskwa National Park, Canada", "Riel House National Historic Site, 330 River Road, Winnipeg, MB, Canada", "Riding Mountain National Park of Canada, Wasagaming, MB R0J 2H0, Canada", "Wanuskewin Heritage Park, RR #4, Penner Road, Saskatoon, SK S7K 3J7, Canada", "Fort Battleford National Historic Site, Battleford, SK, Canada", "Wood Buffalo National Park of Canada, Canada"]);
calcRoute("Jasper National Park, Jasper, AB T0E 1E0, Canada", "Inuvik, NT, Canada", ["Banff National Park, Alberta T0L, Canada", "Stanley Park, Vancouver, BC, Canada", "Prince Rupert, BC, Canada", "Kluane National Park and Reserve of Canada, Yukon Territory Y0B 1H0, Canada", "Dawson Historic Complex, Dawson, YT, Canada"]);
var infowindow = new google.maps.InfoWindow({
content: "Haida Gwaii, Skeena-Queen Charlotte E, BC, Canada"
});
marker = new google.maps.Marker({
position: new google.maps.LatLng(52.648634, -131.810510),
options: markerOptions,
title: "Haida Gwaii, Skeena-Queen Charlotte E, BC, Canada"
});
google.maps.event.addListener(marker, "click", function() {
infowindow.open(map, marker);
});
</script>
</head>
<body>
<div id="map-canvas"></div>
</body>
</html>