forked from startup-systems/mashup
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
90 lines (84 loc) · 2.84 KB
/
index.html
File metadata and controls
90 lines (84 loc) · 2.84 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Mashup</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 95%;
}
h2 {
font-family: Helvetica;
font-size: 1.5em;
font-weight: lighter;
vertical-align: center;
margin-left: 10%;
}
input {
font-size: 1.5em;
font-family: Helvetica;
font-weight: lighter;
padding: .10em;
width: 40%;
}
select {
display: inline-block;
font-size: 1em;
font-family: Helvetica;
font-weight: lighter;
padding: .10em;
-webkit-appearance: menulist-button;
}
</style>
</head>
<body>
<script src="https://code.jquery.com/jquery-3.1.1.js"></script>
<div>
<h2><select id="transpo-method">
<option value="DRIVING">Driving</option>
<option value="WALKING">Walking</option>
<option value="BICYCLING">Biking</option>
<option value="TRANSIT">Public Transport</option>
</select>
directions to Cornell Tech from <input type="text" id="address" name="address" value="" placeholder="100 W 15th St., NYC, NY">
</h2>
</div>
<div id="map"> </div>
<script>
// code for getting map centered on user location from https://developers.google.com/maps/documentation/javascript/examples/map-geolocation
function initMap() {
var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer();
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 40.740403, lng: -74.001534},
zoom: 15
});
directionsDisplay.setMap(map);
function calculateAndDisplayRoute(directionsService, directionsDisplay) {
directionsService.route({origin: document.getElementById("address").value,
destination: '111 8th Ave, New York, NY 10011',
travelMode: document.getElementById('transpo-method').value}, function(response, status){
if (status === 'OK') {
directionsDisplay.setDirections(response);
} else {
window.alert('Directions request failed due to ' + status);
}
});
}
var onChangeHandler = function() {
calculateAndDisplayRoute(directionsService, directionsDisplay);
};
document.getElementById('address').addEventListener('change', onChangeHandler);
document.getElementById('transpo-method').addEventListener('change', onChangeHandler);
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyA_kONVLd5hCd8ZfXi2ldJRlA3CVe-4vqc&callback=initMap" async defer>
</script>
</body>
</html>