sbjw
2025-12-04 ab43548757dee86855061b2d1d458c7db5e6b879
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
import React, {Component} from 'react'
import './ExampleHtmlBoardPage.css'
import {GIS} from "iclient3d-plot-diy";
 
import {Button} from "antd";
import $ from "jquery";
 
export default class ExampleHtmlBoardPage extends Component {
 
    constructor(props) {
        super(props);
        this.state = {
            htmlString: '<h3>正在加载中...</h3>',
            cssString: '<h3>正在加载中...</h3>',
            bp: null,
            clickBpIndex: -1,
        };
    }
 
    options = [
        {
            code: '12xxxx3123',
            "showHtmlBoard": true,
            templateHtml: `
            <div class="info-window">
                <div class="info-window-heading">
                    <span class="info-window-title" style="width: 300px;">{{title}}</span>
                    <div class="bbb">
                         <div class="btn-pin"></div>
                    </div>
                </div>
                <div class="info-window-content-container">
                    <div class="info-window-content">
                        <div class="xxx">
                            <div>名称</div>
                            <div>{{name}}</div>
                        </div>
                        <div class="xxx">
                            <div>经度</div>
                            <div>{{lon}}</div>
                        </div>
                        <div class="xxx">
                            <div>纬度</div>
                            <div>{{lat}}</div>
                        </div>
                    </div>
                </div>
            </div>
        `,
            "templateValue": {
                title: "12xxxx3123",
                name: "name",
                lon: 111.23432,
                lat: 23.1,
            },
            "infoWindowSelector": ".info-window",
            "infoWindowTitleSelector": ".info-window-heading",
            "infoWindowBtnPinSelector": ".btn-pin",
            "type": 2002,
            "useModify": false,
            "lon": 102.74521918551825,
            "lat": 30.982390144247127,
            "height": 0
        },
        {
            code: '12xxxx3122',
            "showHtmlBoard": true,
            "infoWindowSelector": ".info-window",
            "infoWindowTitleSelector": ".info-window-heading",
            "infoWindowBtnPinSelector": ".btn-pin",
            "type": 2002,
            "useModify": false,
            "lon": 112.74521918551825,
            "lat": 30.982390144247127,
            "height": 0
        }
    ]
 
    htmlBoardElementCallback(code){
        let html = `
            <div class="info-window">
                <div class="info-window-heading">
                    <span class="info-window-title" style="width: 300px;">{{title}}</span>
                    <div class="bbb">
                         <div class="btn-pin"></div>
                    </div>
                </div>
                <div class="info-window-content-container">
                    <div class="info-window-content">
                        <div class="xxx">
                            <div>名称</div>
                            <div>{{name}}</div>
                        </div>
                        <div class="xxx">
                            <div>经度</div>
                            <div>{{lon}}</div>
                        </div>
                        <div class="xxx">
                            <div>纬度</div>
                            <div>{{lat}}</div>
                        </div>
                    </div>
                </div>
            </div>
        `
        let values = {
            title: code,
            name: "name",
            lon: 111.23432,
            lat: 23.1,
        };
        html = html.replace(/\{\{(.*)}}/g, (g, g2) => {
            return values[g2] || '';
        });
        return $(html)[0];
    }
 
    componentDidMount() {
 
        fetch('./example/ExampleHtmlBoardPage.md')
            .then(response => response.text())
            .then(mdText => {
                this.setState({htmlString: window.marked.parse(mdText)});
            });
        fetch('./example/ExampleHtmlBoardCss.md')
            .then(response => response.text())
            .then(mdText => {
                this.setState({cssString: window.marked.parse(mdText)});
            });
        let html = `
            <div class="info-window">
                <div class="info-window-heading">
                    <span class="info-window-title" style="width: 300px;">00003 </span>
                    <div class="bbb">
                        <ng-content select="head-button"></ng-content>
                    </div>
                </div>
                <div class="info-window-content-container">
                    <div class="info-window-content">
                        <div class="xxx">
                            <div>名称</div>
                            <div>xxxx</div>
                        </div>
                        <div class="xxx">
                            <div>经度</div>
                            <div>xxxx</div>
                        </div>
                        <div class="xxx">
                            <div>纬度</div>
                            <div>xxxx</div>
                        </div>
                    </div>
                </div>
            </div>
        `;
        // let element = $(html);
        this.mapFunction.mapApiService.showDrawDatas(this.options);
    }
 
    showWindow() {
        // this.mapFunction.mapApiService.showDrawDatas(this.options);
        this.mapFunction.mapApiService.updateDraw('12xxxx3123', {
            "showHtmlBoard": true
        });
    }
    closeWindow() {
        this.mapFunction.mapApiService.updateDraw('12xxxx3123', {
            "showHtmlBoard": false
        });
    }
 
    render() {
        return (
            <div className={"example_draw_container"}>
                <h3>军标绘制拨盘功能</h3>
                <div className={"map_wrapper"}>
                    <GIS refs={
                        e => {
                            this.mapFunction = e
                        }
                    }
                         plotUrl={this.state.plotUrl}
                         mapRef={this}
                         showDefaultLayer={true}
                         htmlBoardElementCallback={this.htmlBoardElementCallback.bind(this)}
                    />
                </div>
                <Button type="primary" onClick={this.showWindow.bind(this)}>打开12xxxx3123窗口</Button>
                <Button type="primary" onClick={this.closeWindow.bind(this)}>关闭12xxxx3123窗口</Button>
                {this.state.clickBpIndex > -1 && <span
                    style={{color: '#f00', marginLeft: '20px'}}>你点击了第 {this.state.clickBpIndex + 1} 个选项!</span>}
                <div className={"code_wrapper"}>
                    <div dangerouslySetInnerHTML={{__html: this.state.htmlString}}></div>
                </div>
                <div className={"code_wrapper"}>
                    <div dangerouslySetInnerHTML={{__html: this.state.cssString}}></div>
                </div>
            </div>
        )
    }
}