-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/antvis/L7Editor into feat…
…/add-tengxun-baidu
- Loading branch information
Showing
19 changed files
with
274 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
48 changes: 48 additions & 0 deletions
48
src/components/map-control-group/export-image-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,48 @@ | ||
import { ExportImageControl } from '@antv/larkmap'; | ||
import { Image, Modal } from 'antd'; | ||
import React, { useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { downloadImg } from '.././../../utils'; | ||
import useStyle from './styles'; | ||
|
||
export const ExportImage = () => { | ||
const styles = useStyle(); | ||
const [imageData, setImageData] = useState(''); | ||
const [isModalOpen, setIsModalOpen] = useState(false); | ||
const { t } = useTranslation(); | ||
|
||
const onExport = (value: string) => { | ||
setIsModalOpen(true); | ||
setImageData(value); | ||
}; | ||
|
||
const handle = () => { | ||
setIsModalOpen(false); | ||
setImageData(''); | ||
}; | ||
|
||
const onOk = () => { | ||
setIsModalOpen(false); | ||
downloadImg(imageData); | ||
setImageData(''); | ||
}; | ||
return ( | ||
<> | ||
<ExportImageControl | ||
onExport={onExport} | ||
className={styles.l7ExportImg} | ||
imageType="jpeg" | ||
position={'bottomright'} | ||
/> | ||
<Modal | ||
title={t('export-img-control_title')} | ||
open={isModalOpen} | ||
okText={t('btn.download_btn.xiaZai')} | ||
onOk={onOk} | ||
onCancel={handle} | ||
> | ||
<Image src={imageData} /> | ||
</Modal> | ||
</> | ||
); | ||
}; |
28 changes: 28 additions & 0 deletions
28
src/components/map-control-group/export-image-control/styles.ts
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,28 @@ | ||
import { css } from '@emotion/css'; | ||
import { theme } from 'antd'; | ||
|
||
const useStyle = () => { | ||
const { useToken } = theme; | ||
const { token } = useToken(); | ||
|
||
const { colorBgContainer, colorIcon, colorText } = | ||
token; | ||
return { | ||
l7ExportImg: css` | ||
background: ${colorBgContainer}; | ||
color: ${colorIcon}; | ||
svg { | ||
fill: ${colorIcon} !important; | ||
} | ||
:hover { | ||
background: ${colorBgContainer} !important; | ||
svg { | ||
color: ${colorText} !important; | ||
fill: ${colorText} !important; | ||
} | ||
} | ||
`, | ||
}; | ||
}; | ||
export default useStyle; |
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.
Oops, something went wrong.