Skip to content

Commit dd812a3

Browse files
author
chenghao
committed
add map components
1 parent 8f72d52 commit dd812a3

File tree

7 files changed

+440
-25
lines changed

7 files changed

+440
-25
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"react-draft-wysiwyg": "^1.10.0",
4747
"react-draggable": "^2.2.6",
4848
"react-error-overlay": "^1.0.9",
49+
"react-qmap": "^0.1.5",
4950
"react-redux": "^5.0.5",
5051
"react-router-dom": "^4.2.2",
5152
"recharts": "^1.0.0-alpha.1",

src/components/ui/map/Tencent.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react';
2+
import ReactQMap from 'react-qmap';
3+
4+
const getContianer = dom => {
5+
const middleControl = document.createElement('div');
6+
middleControl.style.cssText = 'width: 22px;height: 30px;position: absolute;left: 50%;top: 50%;z-index: 999;margin-left: -23px;margin-top: -23px;';
7+
middleControl.innerHTML = `<img src="${require('../../../style/imgs/spot_location.png')}" style="width: 100%;height: 100%;" />`;
8+
dom.appendChild(middleControl);
9+
}
10+
11+
export default () => (
12+
<ReactQMap
13+
center={{latitude: 30.53786, longitude: 104.07265}}
14+
initialOptions={{zoomControl: true, mapTypeControl: true}}
15+
apiKey="UN6BZ-MP2W6-XWCSX-M2ATU-QORGZ-OWFOE"
16+
style={{height: 500}}
17+
mySpot={{latitude: 30.53786, longitude: 104.07265}}
18+
getContainer={getContianer}
19+
/>
20+
);

src/components/ui/map/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from 'react';
2+
import Tencent from './Tencent';
3+
import { Row, Col, Card } from 'antd';
4+
import BreadcrumbCustom from '../../BreadcrumbCustom';
5+
6+
export default () => (
7+
<div>
8+
<BreadcrumbCustom first="UI" second="地图" />
9+
<Row gutter={16}>
10+
<Col md={24}>
11+
<div style={{height: 500}}>
12+
<Card bordered={false} title="腾讯地图">
13+
<Tencent />
14+
</Card>
15+
</div>
16+
</Col>
17+
</Row>
18+
</div>
19+
)

src/constants/menus.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const menus = [
1313
{ key: '/app/ui/wysiwyg', title: '富文本', icon: '', },
1414
{ key: '/app/ui/drags', title: '拖拽', icon: '', },
1515
{ key: '/app/ui/gallery', title: '画廊', icon: '', },
16+
{ key: '/app/ui/map', title: '地图'},
1617
],
1718
},
1819
{

src/routes/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import RouterEnter from '../components/auth/RouterEnter';
2727
import Wysiwyg from 'bundle-loader?lazy!../components/ui/Wysiwyg'; // 按需加载富文本配置
2828
import Bundle from '../components/widget/Bundle';
2929
import Cssmodule from '../components/cssmodule';
30+
import MapUi from '../components/ui/map';
3031

3132
const WysiwygBundle = (props) => (
3233
<Bundle load={Wysiwyg}>
@@ -63,6 +64,7 @@ export default class CRouter extends Component {
6364
<Route exact path="/app/ui/wysiwyg" component={WysiwygBundle} />
6465
<Route exact path="/app/ui/drags" component={Drags} />
6566
<Route exact path="/app/ui/gallery" component={Gallery} />
67+
<Route exact path="/app/ui/map" component={MapUi} />
6668

6769
<Route exact path="/app/animation/basicAnimations" component={BasicAnimations} />
6870
<Route exact path="/app/animation/exampleAnimations" component={ExampleAnimations} />

src/style/imgs/spot_location.png

5.38 KB
Loading

0 commit comments

Comments
 (0)