-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
178 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/components/map-control-group/l7-option-control/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { CustomControl, useScene } from '@antv/larkmap'; | ||
import { Button, Input, Modal, Tooltip, message } from 'antd'; | ||
import Clipboard from 'clipboard'; | ||
import React, { useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { IconFont } from '../../../components/iconfont'; | ||
import useStyles from '../styles'; | ||
|
||
const { TextArea } = Input; | ||
|
||
export const L7MapOptionControl = () => { | ||
const scene = useScene(); | ||
const styles = useStyles(); | ||
const { t } = useTranslation(); | ||
const [isModalOpen, setIsModalOpen] = useState(false); | ||
const [textValue, setTextValue] = useState(''); | ||
|
||
const showModal = () => { | ||
setIsModalOpen(true); | ||
const optionJson = { | ||
center: [scene.getCenter().lng, scene.getCenter().lat], | ||
zoom: scene.getZoom(), | ||
pitch: Number(scene.getPitch().toFixed(6)), | ||
rotation: scene.getRotation(), | ||
}; | ||
setTextValue(JSON.stringify(optionJson, null, 2)); | ||
}; | ||
|
||
const handleOk = () => { | ||
const clipboard = new Clipboard(`#l7-option-copy_btn`, { | ||
text: () => textValue, | ||
}); | ||
|
||
clipboard.on('success', () => { | ||
setIsModalOpen(false); | ||
message.success(t('layer_contextmenu_popup.fuZhiChengGong')); | ||
clipboard.destroy(); | ||
}); | ||
}; | ||
|
||
const handleCancel = () => { | ||
setIsModalOpen(false); | ||
}; | ||
return ( | ||
<CustomControl position="bottomleft"> | ||
<Tooltip placement="left" overlay={t('l7Options.huoqucanshu')}> | ||
<button | ||
className={styles.L7EditorControl} | ||
id="text-layer-control" | ||
onClick={showModal} | ||
> | ||
<IconFont type="icon-xitongzhuangtai" /> | ||
</button> | ||
</Tooltip> | ||
<Modal | ||
title={t('l7Options.dangqiancanshu')} | ||
open={isModalOpen} | ||
onCancel={handleCancel} | ||
width={800} | ||
destroyOnClose | ||
footer={ | ||
<> | ||
<Button onClick={handleCancel}> | ||
{t('btn.setting_btn.guanBi')} | ||
</Button> | ||
<Button type="primary" id="l7-option-copy_btn" onClick={handleOk}> | ||
{t('layer_contextmenu_popup.fuZhi')} | ||
</Button> | ||
</> | ||
} | ||
> | ||
<TextArea | ||
rows={10} | ||
value={textValue} | ||
onChange={(e) => { | ||
setTextValue(e.target.value); | ||
}} | ||
/> | ||
</Modal> | ||
</CustomControl> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.