Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onDrop(e: AntTreeNodeDropEvent) {
const dragLayer = MapUtil.getLayerByOlUid(this.props.map, e.dragNode.props.eventKey);
const dragInfo = MapUtil.getLayerPositionInfo(dragLayer, this.props.map);
const dragCollection = dragInfo.groupLayer.getLayers();
const dropLayer = MapUtil.getLayerByOlUid(this.props.map, e.node.props.eventKey);
const dropPos = e.node.props.pos.split('-');
const location = e.dropPosition - Number(dropPos[dropPos.length - 1]);
dragCollection.remove(dragLayer);
const dropInfo = MapUtil.getLayerPositionInfo(dropLayer, this.props.map);
const dropPosition = dropInfo.position;
const dropCollection = dropInfo.groupLayer.getLayers();
// drop before node
if (location === -1) {
if (dropPosition === dropCollection.getLength() - 1) {
dropCollection.push(dragLayer);
onDrop(e: AntTreeNodeDropEvent) {
const dragLayer = MapUtil.getLayerByOlUid(this.props.map, e.dragNode.props.eventKey);
const dragInfo = MapUtil.getLayerPositionInfo(dragLayer, this.props.map);
const dragCollection = dragInfo.groupLayer.getLayers();
const dropLayer = MapUtil.getLayerByOlUid(this.props.map, e.node.props.eventKey);
const dropPos = e.node.props.pos.split('-');
const location = e.dropPosition - Number(dropPos[dropPos.length - 1]);
dragCollection.remove(dragLayer);
const dropInfo = MapUtil.getLayerPositionInfo(dropLayer, this.props.map);
const dropPosition = dropInfo.position;
const dropCollection = dropInfo.groupLayer.getLayers();
// drop before node
if (location === -1) {
if (dropPosition === dropCollection.getLength() - 1) {
dropCollection.push(dragLayer);
} else {
dropCollection.insertAt(dropPosition + 1, dragLayer);
}
onCheck(checkedKeys: string[], e: AntTreeNodeCheckedEvent) {
const { checked } = e;
const eventKey = e.node.props.eventKey;
const layer = MapUtil.getLayerByOlUid(this.props.map, eventKey);
this.setLayerVisibility(layer, checked);
}