向百度地图中插入多个点...
这种写法貌似不行...
求解释....
1 var count = pointX.length; 2 var polyArray = []; 3 for (i = 0; i < count; i++) {
polyArray[i] = new BMap.Point(pointX[i], pointY[i]); 7 } 8 var polyline = new BMap.Polyline(polyArray, 9 { strokeColor: "blue", strokeWeight: 6, strokeOpacity: 0.5 }); 10 map.addOverlay(polyline);
这样子写就显示...
无语了...
1 var x1 = pointY[0]; 2 var y1 = pointX[0]; 3 var x2 = pointY[1]; 4 var y2 = pointX[1]; 5 var x3 = pointY[2]; 6 var y3 = pointX[2]; 7 var x4 = pointY[3]; 8 var y4 = pointX[3]; 9 var x5 = pointY[4]; 10 var y5 = pointX[4]; 11 var polyArray = []; 12 polyArray[0] = new BMap.Point(x1, y1); 13 polyArray[1] = new BMap.Point(x2, y2); 14 polyArray[2] = new BMap.Point(x3, y3); 15 polyArray[3] = new BMap.Point(x4, y4); 16 polyArray[4] = new BMap.Point(x5, y5); 17 18 var polyline = new BMap.Polyline(polyArray, { strokeColor: "blue", strokeWeight: 6, strokeOpacity: 0.5 }); 19 map.addOverlay(polyline);
不知道哪里写的不对。。
没学过JS...
...