feat(draw): draw circle add change event

This commit is contained in:
thinkinggis 2020-08-21 00:04:30 +08:00
parent a6e0b7f9a8
commit d62de543d4
5 changed files with 125 additions and 113 deletions

View File

@ -88,13 +88,26 @@ export default class DrawCircle extends DrawFeature {
lat: newStartPoint[1],
lng: newStartPoint[0],
};
const newEndPoint = movePoint(
[this.endPoint.lng, this.endPoint.lat],
delta,
);
const endPointObj = {
lat: newEndPoint[1],
lng: newEndPoint[0],
};
newFeature[0].properties = {
...newFeature[0].properties,
startPoint: this.startPoint,
endPoint: endPointObj,
pointFeatures: newPointFeture,
};
this.centerLayer.setData([this.startPoint]);
this.setCurrentFeature(newFeature[0]);
const changeFeature = {
...newFeature[0],
};
this.emit(DrawEvent.CHANGE, changeFeature);
}
protected createFeature(id: string = '0'): Feature {
@ -121,6 +134,7 @@ export default class DrawCircle extends DrawFeature {
this.drawVertexLayer.updateData(
featureCollection(properties.pointFeatures),
);
this.emit(DrawEvent.CHANGE, featureCollection([newFeature]).features[0]);
}
protected showOtherLayer() {

View File

@ -4,6 +4,7 @@ export enum DrawEvent {
Move = 'draw.move',
Edit = 'draw.edit',
UPDATE = 'draw.update',
CHANGE = 'draw.change',
SELECTION_CHANGE = 'draw.selectionchange',
MODE_CHANGE = 'draw.modechange',
ACTIONABLE = 'draw.actionable',

View File

@ -41,7 +41,6 @@ function _pointsGridHash(dataArray: any[], size: number) {
}
}
const centerLat = (latMin + latMax) / 2;
// const centerLat = 34.54083;
const gridOffset = _calculateGridLatLonOffset(size, centerLat);
if (gridOffset.xOffset <= 0 || gridOffset.yOffset <= 0) {
return { gridHash: {}, gridOffset };

View File

@ -32,7 +32,6 @@ export default class HexagonLayerDemo extends React.Component {
)
.then((res) => res.json())
.then((data) => {
console.log(data);
const layer = new HeatmapLayer({})
.source(data, {
transforms: [

View File

@ -65,11 +65,10 @@ export default class HexagonLayerDemo extends React.Component {
].reverse(),
)
.style({
coverage: 0.9,
coverage: 1,
angle: 0,
});
scene.addLayer(pointLayer);
console.log(pointLayer.getSource());
this.scene = scene;
});
});