java脚本中缺少循环 [英] Loop missing in java script
问题描述
你好每一个人
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;
});
这是json对象的位置格式
And this is the format of json object for location
[['14.27537328','80.10244723','NO'],['14.27542356','80.10243269','NO']]
尝试运行时,else语句字符串首先绑定,然后如果条件字符串pls可以找到原因。
我有执行此方法后超时的函数。
请帮助我
我有什么尝试过:
我的数据库中有纬度和经度,在开车时被移动设备捕获。当没有信号时,lat longs没有捕获,所以现在我从驾驶模式谷歌api获取它们并连接到我的json
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
推荐答案
.each(locations,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。驾驶
};
directionsService.route(请求,功能(响应,状态){
如果 (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()+`','`+点[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;
});
.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; });
这是json对象的位置格式
And this is the format of json object for location
[['14.27537328','80.10244723','NO'],['14.27542356','80.10243269','NO']]
尝试运行时,else语句字符串首先绑定,然后如果条件字符串pls可以找到原因。
我有执行此方法后超时的函数。
请帮助我
我有什么尝试过:
我的数据库中有纬度和经度,在开车时被移动设备捕获。当没有信号时,拉特长子没有捕获,所以现在我从驾驶模式谷歌api中取出它们并连接到我的json
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
这篇关于java脚本中缺少循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!