add
sbjw
2025-12-09 ebab191767e28d8c3cb24f8c376c67fa69709c8c
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
import React, {Component} from 'react'
import './ExampleDrawPage.css'
import {GIS} from "iclient3d-plot-diy";
 
import {Button} from "antd";
 
export default class Example2DDrawUpdatePage extends Component {
 
 
    optionObjs = {
        "目标醒目": {
            code: '123',
            type: "2002",
            xz: true,
            xzColor: '#00ff00',
            xx: true,
            xxColor: '#ff0000',
            iconColor: '#dddddd',
            returnHeight: true,
            useModify: false,
            lon: 102.23554539488224,
            lat: 31.005068100060593,
            height: 0,
            points: []
        },
    }
    line_star
    drawOps = [];
 
    constructor(props) {
        super(props);
        this.state = {
            htmlString: '<h3>正在加载中...</h3>',
            plotText: ''
        };
    }
 
    componentDidMount() {
        fetch('./example/Example2DDrawUpdatePage.md')
            .then(response => response.text())
            .then(mdText => {
                this.setState({htmlString: window.marked.parse(mdText)});
            });
        this.showOptions();
 
        let index = 0;
        let f = () => {
            index++;
            this.mapFunction.mapApiService.updateDraw('123', {
                lon: 102.23554539488224,
                lat: 31.005068100060593,
                height: index * 1000
            })
            let dd = this.mapFunction.mapApiService.exportDraw('123');
            this.setState({
                plotText : JSON.stringify(dd)
            });
            if (index < 10) {
                setTimeout(f, 1000)
            }
        }
        f();
    }
 
    showOptions = () => {
        if (this.mapFunction) {
            let options = [];
            for (let key in this.optionObjs) {
                options.push(this.optionObjs[key]);
            }
            this.mapFunction.mapApiService.showDrawDatas(options);
        }
    };
 
 
    async draw(option) {
        option = JSON.parse(JSON.stringify(option));
        option.useModify = true;
        delete option.points;
        delete option.lon;
        delete option.lat;
        delete option.height;
        let p = await this.mapFunction.mapApiService.draw(option);
        p.drawEnd.subscribe(value => {
            // alert(p.export());
        })
        this.drawOps.push(p);
    }
 
    export() {
        let op = [];
        let draws = this.mapFunction.mapApiService.getAllDraw();
        for (let d of draws) {
            let dd = this.mapFunction.mapApiService.exportDraw(d.code);
            if (dd) {
                op.push(dd);
            }
        }
        console.log(op);
    }
 
    render() {
        let buttons = [];
        let obs = JSON.parse(JSON.stringify(this.optionObjs));
        for (let key in obs) {
            let option = obs[key];
            buttons.push(<Button type="primary" onClick={this.draw.bind(this, option)} key={key}>{key}</Button>);
        }
 
        return (
            <div className={"example_draw_container"}>
                <h3>军标绘制/展示已有的军标数据</h3>
                <div className={"map_wrapper"}>
                    <GIS refs={
                        e => {
                            this.mapFunction = e
                        }
                    }
                         useSvgIcon={true}
                         iconScales={[[0, 2000], [2000, 10000], [10000, 5000000]]}
                         plotUrl={this.state.plotUrl}
                         mapRef={this}
                         map2D={true}
                         showDefaultLayer={false}
                    />
                </div>
                {this.state.plotText}
                <div className={"code_wrapper"}>
                    <div dangerouslySetInnerHTML={{__html: this.state.htmlString}}></div>
                </div>
            </div>
        )
    }
}