Repository navigation
Expand file tree
/
Copy pathrouting.js
More file actions
65 lines (54 loc) · 1.7 KB
/
Copy pathrouting.js
File metadata and controls
65 lines (54 loc) · 1.7 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
var dists = [5000];
function calculateRoute(id, startLatLng, endLatLng)
{
$('#routes a[id*="rota"]').removeClass("active");
$("#rota" + id).addClass("active");
var startLat = startLatLng.split(",")[0];
var startLong = startLatLng.split(",")[1];
startLatLng = new google.maps.LatLng(startLat, startLong);
var endLat = endLatLng.split(",")[0];
var endLong = endLatLng.split(",")[1];
endLatLng = new google.maps.LatLng(endLat, endLong);
var request = {
origin: startLatLng,
destination: endLatLng,
optimizeWaypoints: true,
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC
};
directionsService.route(request, function (directionResult, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsRenderer.setDirections(directionResult);
GetProblems();
}
});
google.maps.event.addListener(directionsRenderer, 'directions_changed', function () {
/* NOT USED */
});
var destination = endLatLng;
var bounds = new google.maps.LatLngBounds();
bounds.extend(destination);
map.fitBounds(bounds);
}
function calculateRouteByAddress(id, startAddress, endAddress)
{
$('#routes a[id*="rota"]').removeClass("active");
$("#rota" + id).addClass("active");
var request = {
origin: startAddress,
destination: endAddress,
optimizeWaypoints: true,
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC
};
directionsService.route(request, function (directionResult, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsRenderer.setDirections(directionResult);
GetProblems();
}
});
google.maps.event.addListener(directionsRenderer, 'directions_changed', function () {
/* NOT USED */
});
}