-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
77 lines (68 loc) · 2.16 KB
/
index.html
File metadata and controls
77 lines (68 loc) · 2.16 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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<title>KML Layers</title>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var mapCenter = {lat: -36.8629404, lng: 174.7250425};
var kmlFile = 'http://matveytn.github.io/Google-maps-API-test/busstop.kml';
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 11,
center: mapCenter,
});
var kmlLayer = new google.maps.KmlLayer({
url: kmlFile,
map: map
});
}
var originA = new google.maps.LatLng(174.77465, -36.89261, 0);
var destinationA = new google.maps.LatLng(50.087692, 14.421150);
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix(
{
origins: [originA],
destinations: [destinationA],
travelMode: 'DRIVING',
transitOptions: TransitOptions,
drivingOptions: DrivingOptions,
unitSystem: UnitSystem,
avoidHighways: Boolean,
avoidTolls: Boolean,
}, callback);
function callback(response, status) {
if (status == 'OK') {
var origins = response.originAddresses;
var destinations = response.destinationAddresses;
for (var i = 0; i<origins.length; i++) {
var results = response.rows[i].elements;
for (var j = 0; j<results.length; j++) {
var element = results[j];
var distance = element.distance.text;
var duration = element.duration.text;
var from = origins[i];
var to = destinations[j];
}
}
}
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBAbaVnGNkLP6T9y0ujBg-3ucg3cQellwE&callback=initMap">
</script>
</body>
</html>