-
Notifications
You must be signed in to change notification settings - Fork 79
/
chevrolet-family-road-trip-ne.html
231 lines (173 loc) · 10.2 KB
/
chevrolet-family-road-trip-ne.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<!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="The Northeast Family Road Trip by Chevrolet.">
<meta name="author" content="Chevrolet">
<title>The Northeast Family Road Trip by Chevrolet</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 marker1, marker2, marker3, marker4, marker5, marker6, marker7, marker8, marker9, marker10;
var infoWindows = [];
var markerOptions = {icon: "http://maps.gstatic.com/mapfiles/markers2/marker.png"};
var routeMarkerOptions = {visible: false, zIndex: 0};
var directionsDisplayOptions = {preserveViewport: true,
markerOptions: routeMarkerOptions};
var directionsService = new google.maps.DirectionsService();
var map;
function initialize() {
var center = new google.maps.LatLng(40.727675, -73.985174);
var mapOptions = {
zoom: 7,
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);
}
marker1.setMap(map); marker2.setMap(map); marker3.setMap(map); marker4.setMap(map); marker5.setMap(map); marker6.setMap(map); marker7.setMap(map); marker8.setMap(map); marker9.setMap(map); marker10.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 = ['4 Yawkey Way, Boston, MA 02215', '19 1/2 Washington Square, Salem, MA 01970', '12 Captain Strout Cir, Cape Elizabeth, ME 04107 ', 'N 6th St & Market St, Philadelphia, PA 19106', '101 S Henry St, Williamsburg, VA 23185', '3001 Connecticut Ave NW, Washington, DC 20008', 'Cape May, New Jersey 08204', '2300 Southern Blvd, Bronx, NY 10460', ' 67 River Rd, East Haddam, CT 06423', '424 Bellevue Ave, Newport, RI 02840']
createRoutes(optimal_route);
google.maps.event.addDomListener(window, 'load', initialize);
var infoWindow1 = new google.maps.InfoWindow({ content: "<h3>Fenway Park<br />4 Yawkey Way, Boston, MA 02215</h3>"});
infoWindows.push(infoWindow1);
marker1 = new google.maps.Marker({
position: new google.maps.LatLng(42.34584359999999, -71.09878189999999),
options: markerOptions,
title: "Fenway Park"
});
google.maps.event.addListener(marker1, "mouseover", function() { for (var i = 0; i < infoWindows.length; i++) { infoWindows[i].close(); }; infoWindow1.open(map, marker1); });
var infoWindow2 = new google.maps.InfoWindow({ content: "<h3>Salem Witch Museum<br />19 1/2 Washington Square, Salem, MA 01970</h3>"});
infoWindows.push(infoWindow2);
marker2 = new google.maps.Marker({
position: new google.maps.LatLng(42.523651, -70.8910922),
options: markerOptions,
title: "Salem Witch Museum"
});
google.maps.event.addListener(marker2, "mouseover", function() { for (var i = 0; i < infoWindows.length; i++) { infoWindows[i].close(); }; infoWindow2.open(map, marker2); });
var infoWindow3 = new google.maps.InfoWindow({ content: "<h3>Portland Head Light and Fort Williams Park<br />12 Captain Strout Cir, Cape Elizabeth, ME 04107 </h3>"});
infoWindows.push(infoWindow3);
marker3 = new google.maps.Marker({
position: new google.maps.LatLng(43.623104, -70.2081123),
options: markerOptions,
title: "Portland Head Light and Fort Williams Park"
});
google.maps.event.addListener(marker3, "mouseover", function() { for (var i = 0; i < infoWindows.length; i++) { infoWindows[i].close(); }; infoWindow3.open(map, marker3); });
var infoWindow4 = new google.maps.InfoWindow({ content: "<h3>Liberty Bell<br />N 6th St & Market St, Philadelphia, PA 19106</h3>"});
infoWindows.push(infoWindow4);
marker4 = new google.maps.Marker({
position: new google.maps.LatLng(39.9507426, -75.15037459999999),
options: markerOptions,
title: "Liberty Bell"
});
google.maps.event.addListener(marker4, "mouseover", function() { for (var i = 0; i < infoWindows.length; i++) { infoWindows[i].close(); }; infoWindow4.open(map, marker4); });
var infoWindow5 = new google.maps.InfoWindow({ content: "<h3>Colonial Williamsburg<br />101 S Henry St, Williamsburg, VA 23185</h3>"});
infoWindows.push(infoWindow5);
marker5 = new google.maps.Marker({
position: new google.maps.LatLng(37.2707562, -76.7055796),
options: markerOptions,
title: "Colonial Williamsburg"
});
google.maps.event.addListener(marker5, "mouseover", function() { for (var i = 0; i < infoWindows.length; i++) { infoWindows[i].close(); }; infoWindow5.open(map, marker5); });
var infoWindow6 = new google.maps.InfoWindow({ content: "<h3>National Zoo<br />3001 Connecticut Ave NW, Washington, DC 20008</h3>"});
infoWindows.push(infoWindow6);
marker6 = new google.maps.Marker({
position: new google.maps.LatLng(38.9319273, -77.0524404),
options: markerOptions,
title: "National Zoo"
});
google.maps.event.addListener(marker6, "mouseover", function() { for (var i = 0; i < infoWindows.length; i++) { infoWindows[i].close(); }; infoWindow6.open(map, marker6); });
var infoWindow7 = new google.maps.InfoWindow({ content: "<h3>Cape May<br />Cape May, New Jersey 08204</h3>"});
infoWindows.push(infoWindow7);
marker7 = new google.maps.Marker({
position: new google.maps.LatLng(38.9351125, -74.90600529999999),
options: markerOptions,
title: "Cape May"
});
google.maps.event.addListener(marker7, "mouseover", function() { for (var i = 0; i < infoWindows.length; i++) { infoWindows[i].close(); }; infoWindow7.open(map, marker7); });
var infoWindow8 = new google.maps.InfoWindow({ content: "<h3>The Bronx Zoo<br />2300 Southern Blvd, Bronx, NY 10460</h3>"});
infoWindows.push(infoWindow8);
marker8 = new google.maps.Marker({
position: new google.maps.LatLng(40.8502883, -73.8786113),
options: markerOptions,
title: "The Bronx Zoo"
});
google.maps.event.addListener(marker8, "mouseover", function() { for (var i = 0; i < infoWindows.length; i++) { infoWindows[i].close(); }; infoWindow8.open(map, marker8); });
var infoWindow9 = new google.maps.InfoWindow({ content: "<h3>Gillette Castle State Park<br />67 River Rd, East Haddam, CT 06423</h3>"});
infoWindows.push(infoWindow9);
marker9 = new google.maps.Marker({
position: new google.maps.LatLng(41.4271657, -72.4286718),
options: markerOptions,
title: "Gillette Castle State Park"
});
google.maps.event.addListener(marker9, "mouseover", function() { for (var i = 0; i < infoWindows.length; i++) { infoWindows[i].close(); }; infoWindow9.open(map, marker9); });
var infoWindow10 = new google.maps.InfoWindow({ content: "<h3>Newport Mansions<br />424 Bellevue Ave, Newport, RI 02840</h3>"});
infoWindows.push(infoWindow10);
marker10 = new google.maps.Marker({
position: new google.maps.LatLng(41.4750152, -71.3072335),
options: markerOptions,
title: "Newport Mansions"
});
google.maps.event.addListener(marker10, "mouseover", function() { for (var i = 0; i < infoWindows.length; i++) { infoWindows[i].close(); }; infoWindow10.open(map, marker10); });
</script>
</head>
<body>
<div id="map-canvas"></div>
<!-- <a href="https://www.chevrolet.com/"><img src="images/chevrolet-logo.png" width="400px" style="position: absolute; bottom: 35px; left: 7px;" /></a> -->
</body>
</html>