js中的for循环,循环次数会多出一次。当循环到最后一个的时候,循环还会继续,并且此时i就变成remove?
functiondrawLine(){varisZoom=false;varstr="39.917116.397,39.95970557116.31800626,40.0...
function drawLine() {
var isZoom = false;
var str = "39.917 116.397,39.95970557 116.31800626,40.0434876 116.33688445";
var points = str.split(",");
var markers = [];
var pos = [];
var bb = new hollymapsupport.handle.bounds(map);
for (i in points) {
if(i=="remove") break;
var point = points[i].split(" ");
var myPoint = new hollymapsupport.point(point[0], point[1],
null);
pos.push(myPoint);
var m = map.addMarker(myPoint, "划线点" + i, true, null, null)
markers.push(m);
drawMarkerList.push(m);
ma.push(m);
if (isZoom) {
bb.extend(myPoint);
}
}
drawLineList.push(hollymapsupport.draw.beeline(map, markers));
};
function drawLine() {
var isZoom = false;
var str = "39.917 116.397,39.95970557 116.31800626,40.0434876 116.33688445";
var points = str.split(",");
var markers = [];
var pos = [];
var bb = new hollymapsupport.handle.bounds(map);
for (i in points) {
if(i=="remove") break;
var point = points[i].split(" ");
var myPoint = new hollymapsupport.point(point[0], point[1],
null);
pos.push(myPoint);
var m = map.addMarker(myPoint, "划线点" + i, true, null, null)
markers.push(m);
drawMarkerList.push(m);
ma.push(m);
if (isZoom) {
bb.extend(myPoint);
}
}
drawLineList.push(hollymapsupport.draw.beeline(map, markers));
}; 展开
var isZoom = false;
var str = "39.917 116.397,39.95970557 116.31800626,40.0434876 116.33688445";
var points = str.split(",");
var markers = [];
var pos = [];
var bb = new hollymapsupport.handle.bounds(map);
for (i in points) {
if(i=="remove") break;
var point = points[i].split(" ");
var myPoint = new hollymapsupport.point(point[0], point[1],
null);
pos.push(myPoint);
var m = map.addMarker(myPoint, "划线点" + i, true, null, null)
markers.push(m);
drawMarkerList.push(m);
ma.push(m);
if (isZoom) {
bb.extend(myPoint);
}
}
drawLineList.push(hollymapsupport.draw.beeline(map, markers));
};
function drawLine() {
var isZoom = false;
var str = "39.917 116.397,39.95970557 116.31800626,40.0434876 116.33688445";
var points = str.split(",");
var markers = [];
var pos = [];
var bb = new hollymapsupport.handle.bounds(map);
for (i in points) {
if(i=="remove") break;
var point = points[i].split(" ");
var myPoint = new hollymapsupport.point(point[0], point[1],
null);
pos.push(myPoint);
var m = map.addMarker(myPoint, "划线点" + i, true, null, null)
markers.push(m);
drawMarkerList.push(m);
ma.push(m);
if (isZoom) {
bb.extend(myPoint);
}
}
drawLineList.push(hollymapsupport.draw.beeline(map, markers));
}; 展开
2个回答
展开全部
for (i in points) 改成 for(var i = 0; i < points,length; i++)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我的也出现这种现象,但是不知道为什么,最后我也改为 i++ 这种了 ,我想问一下 xiaoji123pt 你知道原因不
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询