-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
71 lines (60 loc) · 2.63 KB
/
Copy pathtest.html
File metadata and controls
71 lines (60 loc) · 2.63 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
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>Zomato test maps</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCqPwD-lQNxWqoHMPX9_0UckQlfBVlPVeY&sensor=FALSE"></script>
<script>
/* calculate distance */
var origin1 = new google.maps.LatLng(28.4991670000, 77.1616670000);
var destinationA = 'Mehrauli Gurgaon Rd, Ghitorni, New Delhi, Delhi 110070';
function calculateDistances() {
var service = new google.maps.DistanceMatrixService();
$.get("findexits.php?metro_id=1", function(data, status) {
if (status === "success")
{
var jsondata = JSON.parse(JSON.stringify(data));
alert(jsondata);
return;
}
});
service.getDistanceMatrix(
{
origins: [origin1],
destinations: [destinationA],
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC,
avoidHighways: false,
avoidTolls: false
}, callback);
}
function callback(response, status) {
if (status != google.maps.DistanceMatrixStatus.OK) {
alert('Error was: ' + status);
} else {
var origins = response.originAddresses;
var destinations = response.destinationAddresses;
//alert(response);
for (var i = 0; i < origins.length; i++) {
var results = response.rows[i].elements;
for (var j = 0; j < results.length; j++) {
console.log(origins[i] + ' to ' + destinations[j]
+ ': ' + results[j].distance.text + ' in '
+ results[j].duration.text + '<br>');
}
}
}
}
calculateDistances();
</script>
</body>
</html>