sbjw
2025-08-13 524213932e59cfb0bc70450b6f9accdee5cc9783
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
import React, {Component} from 'react'
import './ExamplePage.css'
import "./CommonExample.css";
import {GIS} from "iclient3d-plot-diy";
 
;
import ProfileTool from "./profile/ProfileTool";
import ProfilePage from "./profile/ProfilePage";
 
export default class ExampleCustomToolbarPage extends Component {
    constructor(props) {
        super(props);
        this.state = {
            profileVisible: false,
            profileResult: null,
            htmlString: '<h3>正在加载中...</h3>'
        };
    }
 
    toolbars = [
        'global',
        'fullscreen',
        'measureDistance',
        'measureArea',
        'seethrough',
        {
            key: 'profile',
            icon: 'profile',
            title: '剖面分析',
            titleI18n: 'profile',
            handleClick: () => {
                this.doProfile();
            }
        },
    ];
 
    componentDidMount() {
        fetch('./example/ExampleCustomToolbarPage.md')
            .then(response => response.text())
            .then(mdText => {
                this.setState({htmlString: window.marked.parse(mdText)});
            });
 
        //启用旋转和倾斜
        this.mapFunction.mapApiService.enableTilt();
    }
 
    doProfile() {
        this.profileVisible = !this.profileVisible;
        this.setState({
            profileVisible: this.profileVisible
        })
    }
 
    callProfile(profileResult) {
        this.setState({
            profileResult: profileResult
        })
    }
 
    render() {
        return (
            <div className={"example"}>
                <h3>分组数据展示</h3>
                <div className={"map_wrapper"}>
                    <GIS refs={
                        e => {
                            this.mapFunction = e
                        }
                    }
                         mapRef={this}
                         showDefaultLayer={true}
                         toolbars={this.toolbars}
                    />
                </div>
                {this.state.profileVisible &&
                    <ProfileTool
                        mapApiService={this.mapFunction.mapApiService}
                        closeEvent={this.doProfile.bind(this)}
                        i18n={this.i18n}
                        callBack={this.callProfile.bind(this)}
                    />}
                {this.state.profileResult &&
                    <ProfilePage
                        mapApiService={this.mapFunction.mapApiService}
                        profileResult={this.state.profileResult}
                        i18n={this.i18n}
                        closeEvent={this.callProfile.bind(this)}
                    />}
                <div className={"code_wrapper"}>
                    <div dangerouslySetInnerHTML={{__html: this.state.htmlString}}></div>
                </div>
            </div>
        )
    }
}