Hello every one
<pre> $.each(locations, function (i, item) {
if((app.distance(pastlatlong, item[0]+","+ item[1]))>0)
{
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
directionsDisplay = new google.maps.DirectionsRenderer();
var start = pastlatlong;
var end = item[0]+","+ item[1];
var request = {
origin: start,
destination: end,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function (response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
if (response.routes && response.routes.length > 0) {
var routes = response.routes;
for (var j = 0; j < routes.length; j++) {
var points = routes[j].overview_path;
for (var i = 0; i < points.length; i++) {
document.getElementById("alllatlng").value=
document.getElementById("alllatlng").value+`['`+points[i].lat()+`','`+ points[i].lng()+`',`+`'FIRST'],`;
}
}
}
}
});
}
else
{
document.getElementById("alllatlng").value=
document.getElementById("alllatlng").value+`['`+item[0]+`','`+ item[1]+`','`+item[2]+`'],`;
}
pastlatlong=item[0]+","+ item[1];
isPaused = false;
});
And this is the format of json object for location
[['14.27537328','80.10244723','NO'],['14.27542356','80.10243269','NO']]
when trying to run this the else statement string is binding first and then if condition string pls can any one find the cause.
Iam having a function with timeout after this method execution.
Please help me
What I have tried:
I have latitudes and longitudes in my database which was captured by mobile while driving. when there was no signal the lat longs have not captured so now I am fetching them from google api in driving mode and concatenating to my json