Merge pull request #317 from antvis/fix_draw

fix(draw): draw control event
This commit is contained in:
@thinkinggis 2020-05-05 22:22:54 +08:00 committed by GitHub
commit e0c9f5cff0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View File

@ -142,7 +142,7 @@ export class DrawControl extends Control {
if (this.draw[draw]) {
['draw.create', 'draw.update', 'draw.delete'].forEach(
(type: string) => {
this.draw[draw].on('draw.create', (feature) => {
this.draw[draw].on(type, (feature) => {
this.emit(type, {
drawType: draw,
feature,

View File

@ -1,5 +1,5 @@
import { LineLayer, PointLayer, PolygonLayer, Popup, Scene } from '@antv/l7';
import { DrawCircle } from '@antv/l7-draw';
import { DrawPolygon } from '@antv/l7-draw';
import { GaodeMap, Mapbox } from '@antv/l7-maps';
import * as React from 'react';
@ -23,13 +23,13 @@ export default class Circle extends React.Component {
this.scene = scene;
scene.on('loaded', () => {
const drawCircle = new DrawCircle(scene);
const drawCircle = new DrawPolygon(scene);
drawCircle.enable();
drawCircle.on('draw.create', (e: any) => {
console.log(e);
});
drawCircle.on('draw.update', (e: any) => {
console.log(e);
console.log('update', e);
});
});
}

View File

@ -36,6 +36,9 @@ export default class Circle extends React.Component {
},
});
scene.on('click', () => {});
drawControl.on('draw.update', (e: any) => {
console.log('update', e);
});
scene.addControl(drawControl);
});
}