polyline画不出来
myAmapFun.getWalkingRoute({ origin: '116.352622,39.993029' , destination: '116.352091,39.990091' , // origin: that.data.nowplacelongitude + ',' + that.data.nowplacelatitude, // destination: that.data.toplace.longitude + ',' + that.data.toplace.latitude, success: function (data) { var points = []; if (data.paths && data.paths[0] && data.paths[0].steps) { var steps = data.paths[0].steps; for ( var i = 0; i < steps.length; i++) { var poLen = steps[i].polyline.split( ';' ); for ( var j = 0; j < poLen.length; j++) { points.push({ longitude: parseFloat(poLen[j].split( ',' )[0]), latitude: parseFloat(poLen[j].split( ',' )[1]) }) } } } that.setData({ polyline: [{ points: points, color: "#0091ff" , width: 6 }] }); if (data.paths[0] && data.paths[0].distance) { that.setData({ distance: data.paths[0].distance + '米' }); } if (data.paths[0] && data.paths[0].duration) { that.setData({ cost: parseInt(data.paths[0].duration / 60) + '分钟' }); } }, fail: function (info) { } }) }, |
我把代码里的origin和destination直接写成数值那样,polyline就会画出。
但是!!
写成注释掉的那个状态就画不出来!!可是看AppData里的返回数据,that.data.nowplacelongitude对应的就是116.352622,that.data.nowplacelatitude对应的就是39.993029,that.data.toplace.longitude就是116.352091,that.data.toplace.latitude对应的是39.990091啊。。。。
纠结了三天了,不知道要写成什么样子
所以动态加载要写成什么样子,请告知,感激不尽。