1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
| import React, {Component} from 'react'
| import './CommonExample.css'
| import {GIS} from "iclient3d-plot-diy";
| import {Button} from "antd";
|
| export default class ExampleSimpleEventPage extends Component {
| drawOps = [];
|
| constructor(props) {
| super(props);
| this.state = {
| htmlString: '<h3>正在加载中...</h3>',
| };
| }
|
| componentDidMount() {
| this.showData();
|
| fetch('./example/ExampleSimpleEventPage.md')
| .then(response => response.text())
| .then(mdText => {
| this.setState({htmlString: window.marked.parse(mdText)});
| });
| //监听拨盘事件
| this.mapFunction.mapApiService.showDrawDatas([{
| code: 'asdladjakl',
| bz: true,
| bzColor: '#e000ff',
| bzLineColor: '#ff0000',
| bzlx: 'simple',
| jbwb: 'R:00017',
| type: "2002",
| returnHeight: true,
| useModify: false,
| lon: 102.33054539488224,
| lat: 31.005468100060593,
| height: 0,
| points: [],
| iconSize: [[20, 20], [30, 30], [40, 40]]
| }, {
| type: 'yhqy',
| code: 'xxcxvawda',
| points: [{lon: 102.642853926199, lat: 31.012509646376447, height: 0},
| {lon: 102.65927322610115, lat: 31.01540811637356, height: 0},
| {lon: 102.66192135373299, lat: 31.005988487769518, height: 0},
| {lon: 102.64755620178961, lat: 31.00246196283815, height: 0},
| {lon: 102.642853926199, lat: 31.012509646376447, height: 0}],
| useModify: false,
|
| }])
| }
|
| showData() {
| // 左击 如果需要dom时的监听
| this.mapFunction.addEventListener((id, overlay, primitive, data) => {
| alert('gis组件的左击事件:' + id);
| }, this);
|
| // 左击如果需要底层对象的监听
| this.mapFunction.mapClickEvent.addEventListener((id, primitive, isPoint) => {
| console.log(id, primitive, isPoint);
| alert('左击事件:' + id);
| }, this);
|
| // 右键监听
| this.mapFunction.mapApiService.mapRightClickEvent.addEventListener((id, primitive, isPoint) => {
| console.log(id, primitive, isPoint);
| alert('右击事件' + id);
| }, this);
| }
|
| drawPolygon() {
| //监听拨盘事件
| this.mapFunction.mapApiService.draw({
| code: 'xxcx_new_',
| type: 'yhqy',
| useModify: true,
| });
| }
|
| render() {
| return (
| <div className={"example_fwy_container"}>
| <h3>自定义事件</h3>
| <div className={"map_wrapper"}>
| <GIS refs={e => {
| this.mapFunction = e
| }}
| plotUrl={this.state.plotUrl}
| mapRef={this}
| showDefaultLayer={true}
| />
| </div>
| <Button type="primary" onClick={this.drawPolygon.bind(this)}>新画一个面</Button>
| <div className={"code_wrapper"}>
| <div dangerouslySetInnerHTML={{__html: this.state.htmlString}}></div>
| </div>
| </div>
| )
| }
| }
|
|