Merge pull request #335 from antvis/fix_draw

fix(draw): fix draw rect bug
This commit is contained in:
@thinkinggis 2020-05-08 14:19:45 +08:00 committed by GitHub
commit 523500c334
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -92,6 +92,8 @@ export default abstract class DrawFeature extends DrawMode {
} }
public clear() { public clear() {
this.drawLayer.disableSelect();
this.drawLayer.disableEdit();
this.drawLayer.hide(); this.drawLayer.hide();
this.drawVertexLayer.hide(); this.drawVertexLayer.hide();
this.hideOtherLayer(); this.hideOtherLayer();
@ -197,6 +199,8 @@ export default abstract class DrawFeature extends DrawMode {
break; break;
case DrawModes.STATIC: case DrawModes.STATIC:
this.source.updateFeature(this.currentFeature as Feature); this.source.updateFeature(this.currentFeature as Feature);
this.selectMode.disable();
this.editMode.disable();
this.source.clearFeatureActive(); this.source.clearFeatureActive();
this.drawVertexLayer.hide(); this.drawVertexLayer.hide();
this.drawVertexLayer.disableEdit(); this.drawVertexLayer.disableEdit();
@ -218,7 +222,9 @@ export default abstract class DrawFeature extends DrawMode {
}; };
private onDrawMove = (delta: ILngLat) => { private onDrawMove = (delta: ILngLat) => {
this.moveFeature(delta); if (this.drawStatus === 'DrawSelected') {
this.moveFeature(delta);
}
}; };
private onDrawEdit = (endpoint: ILngLat) => { private onDrawEdit = (endpoint: ILngLat) => {
@ -231,7 +237,9 @@ export default abstract class DrawFeature extends DrawMode {
this.source.removeFeature(this.currentFeature as Feature); this.source.removeFeature(this.currentFeature as Feature);
this.normalLayer.update(this.source.data); this.normalLayer.update(this.source.data);
this.drawLayer.disableSelect(); this.drawLayer.disableSelect();
this.selectMode.disable();
this.currentFeature = null; this.currentFeature = null;
// this.drawStatus = 'DrawDelete';
} }
}; };

View File

@ -17,7 +17,8 @@ export type DrawStatus =
| 'DrawSelected' | 'DrawSelected'
| 'DrawEdit' | 'DrawEdit'
| 'DrawFinish' | 'DrawFinish'
| 'EditFinish'; | 'EditFinish'
| 'DrawDelete';
let DrawFeatureId = 0; let DrawFeatureId = 0;