Commit bd9f1393 authored by aoobao's avatar aoobao

fix: 当擦除整条线段时发生的bug问题

parent 1bd4bbea
...@@ -85,6 +85,8 @@ export default class LineManager { ...@@ -85,6 +85,8 @@ export default class LineManager {
ctx.save() ctx.save()
this._lines.forEach(lineObj => { this._lines.forEach(lineObj => {
let pixels = lineObj.pixels let pixels = lineObj.pixels
// fix : 当线段全部被擦除的时候,pixels数组为空,跳过绘制 2019-4-25
if (pixels && pixels.length > 0) {
// 线条颜色 // 线条颜色
ctx.strokeStyle = lineObj.color ? lineObj.color : this._color ctx.strokeStyle = lineObj.color ? lineObj.color : this._color
ctx.lineWidth = 1 ctx.lineWidth = 1
...@@ -114,8 +116,7 @@ export default class LineManager { ...@@ -114,8 +116,7 @@ export default class LineManager {
ctx.beginPath() ctx.beginPath()
ctx.arc(pixel.getX(), pixel.getY(), lineObj.lastPointSize || this._lastPointSize, 0, 2 * Math.PI) ctx.arc(pixel.getX(), pixel.getY(), lineObj.lastPointSize || this._lastPointSize, 0, 2 * Math.PI)
ctx.fill() ctx.fill()
}
}); });
ctx.restore() ctx.restore()
...@@ -151,7 +152,7 @@ export default class LineManager { ...@@ -151,7 +152,7 @@ export default class LineManager {
delete obj.pixels delete obj.pixels
return obj return obj
}) })
return list return list.filter(t => t.line && t.line.length > 0)
} }
// 擦除 // 擦除
......
...@@ -98,6 +98,10 @@ export default { ...@@ -98,6 +98,10 @@ export default {
center: [120, 30] center: [120, 30]
}) })
this.map.on('click', e => {
console.log(e.lnglat)
})
// // // 测试代码 // // // 测试代码
// setTimeout(() => { // setTimeout(() => {
// this.addLine({ // this.addLine({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment