我正在编写这段代码以在一段时间间隔后调用一个函数,但该函数没有执行它的功能。当我通常调用函数 pus() 它正在运行但使用 setInterval 它不起作用。请给我它的解决方案。
var ltnlg = null;
var flightPlanCoordinates = [];
var nl2 = 10.9646;
var ng2 = 72.8787;
var lt2, ln2;
var ltnlg = null;
function lin() {
flightPlanCoordinates = [
new google.maps.LatLng(29.0167, 77.3833),
new google.maps.LatLng(21.7679, 78.8718),
new google.maps.LatLng(18.9647, 72.8258)
];
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
strokeColor: "#FF0000",
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
pl = new google.maps.Polyline();
// window.setInterval("pus()", 10000);
pus();
}
}
function pus() {
ltnlg = new google.maps.LatLng(nl2, ng2);
flightPlanCoordinates.push(ltnlg);
lt2 = nl2;
n12 = lt2 + 0.0660;
ln2 = ng2;
ng2 = ln2 + 0.0660;
}