forked from rhiever/optimal-roadtrip-usa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
major-landmarks.html
154 lines (138 loc) · 5.78 KB
/
major-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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<!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 the U.S.">
<meta name="author" content="Randal S. Olson">
<title>The optimal road trip across the U.S. 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 routes_list = []
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(39, -96);
var mapOptions = {
zoom: 5,
center: center
};
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
for (i=0; i<routes_list.length; i++) {
routes_list[i].setMap(map);
}
}
function calcRoute(start, end, routes) {
var directionsDisplay = new google.maps.DirectionsRenderer(directionsDisplayOptions);
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) {
directionsDisplay.setDirections(response);
}
});
routes_list.push(directionsDisplay);
}
function createRoutes(route) {
// Google's free map API is limited to 10 waypoints so need to break into batches
route.push(route[0]);
var subset = 0;
while (subset < route.length) {
var waypointSubset = route.slice(subset, subset + 10);
var startPoint = waypointSubset[0];
var midPoints = waypointSubset.slice(1, waypointSubset.length - 1);
var endPoint = waypointSubset[waypointSubset.length - 1];
calcRoute(startPoint, endPoint, midPoints);
subset += 9;
}
}
optimal_route = ["Grand Canyon National Park Lodges, 88 Village Loop Drive, Grand Canyon Village, AZ 86023", "Bryce Canyon National Park, Hwy 63, Bryce, UT",
"Craters of the Moon National Monument & Preserve, Arco, ID",
"Yellowstone National Park, WY 82190",
"Pikes Peak, Colorado",
"Carlsbad Caverns National Park, Carlsbad, NM",
"The Alamo, Alamo Plaza, San Antonio, TX",
"Chickasaw National Recreation Area, 1008 W 2nd St, Sulphur, OK 73086",
"Toltec Mounds, Scott, AR",
"Graceland, Elvis Presley Boulevard, Memphis, TN",
"Vicksburg National Military Park, Clay Street, Vicksburg, MS",
"French Quarter, New Orleans, LA",
"USS Alabama, Battleship Parkway, Mobile, AL",
"Cape Canaveral, FL",
"Okefenokee Swamp Park, Okefenokee Swamp Park Road, Waycross, GA",
"Fort Sumter National Monument, Sullivan's Island, SC",
"Lost World Caverns, Lewisburg, WV",
"Wright Brothers National Memorial Visitor Center, Manteo, NC",
"Mount Vernon, Fairfax County, Virginia",
"White House, Pennsylvania Avenue Northwest, Washington, DC",
"Maryland State House, 100 State Cir, Annapolis, MD 21401",
"New Castle Historic District, Delaware",
"Congress Hall, Congress Place, Cape May, NJ 08204",
"Liberty Bell, 6th Street, Philadelphia, PA",
"Statue of Liberty, Liberty Island, NYC, NY",
"The Mark Twain House & Museum, Farmington Avenue, Hartford, CT",
"The Breakers, Ochre Point Avenue, Newport, RI",
"USS Constitution, Boston, MA",
"Acadia National Park, Maine",
"Omni Mount Washington Resort, Mount Washington Hotel Road, Bretton Woods, NH",
"Shelburne Farms, Harbor Road, Shelburne, VT",
"USS Cod Submarine Memorial, East 9th Street, Cleveland, OH",
"Olympia Entertainment, Woodward Avenue, Detroit, MI",
"Spring Grove Cemetery, Spring Grove Avenue, Cincinnati, OH",
"Mammoth Cave National Park, Mammoth Cave Pkwy, Mammoth Cave, KY",
"West Baden Springs Hotel, West Baden Avenue, West Baden Springs, IN",
"Lincoln Home National Historic Site Visitor Center, 426 South 7th Street, Springfield, IL",
"Gateway Arch, Washington Avenue, St Louis, MO",
"C. W. Parker Carousel Museum, South Esplanade Street, Leavenworth, KS",
"Terrace Hill, Grand Avenue, Des Moines, IA",
"Taliesin, County Road C, Spring Green, Wisconsin",
"Fort Snelling, Tower Avenue, Saint Paul, MN",
"Ashfall Fossil Bed, Royal, NE",
"Mount Rushmore National Memorial, South Dakota 244, Keystone, SD",
"Fort Union Trading Post National Historic Site, Williston, North Dakota 1804, ND",
"Glacier National Park, 64 Grinnell Drive, West Glacier, MT 59936",
"Hanford Site, Benton County, WA",
"Columbia River Gorge National Scenic Area, Oregon",
"Cable Car Museum, 94108, 1201 Mason St, San Francisco, CA 94108",
"San Andreas Fault, San Benito County, CA",
"Hoover Dam, Boulder City, CO",
"Grand Canyon National Park Lodges, 88 Village Loop Drive, Grand Canyon Village, AZ 86023"]
createRoutes(optimal_route);
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
</body>
</html>