sbjw
2025-09-01 9f6d02dc2c2647076d4b56fce62a347188462c5a
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
import React, {Component} from 'react'
import './ExamplePage.css'
import "./CommonExample.css";
import {GIS} from "iclient3d-plot-diy";
 
;
import {Button} from "antd";
 
export default class ExampleI18nPage extends Component {
    constructor(props) {
        super(props);
        this.state = {
            htmlString: '<h3>正在加载中...</h3>'
        };
    }
 
    toolbars = [
        'global',
        'fullscreen',
        'measureDistance',
        'measureArea',
        'seethrough',
        {
            key: 'seethrough2',
            icon: 'seethrough',
            titleI18n: 'seethrough2',
            handleClick: () => {
                alert('new toolbar')
            }
        },
    ];
 
    i18nObj = {
        seethrough2: {
            'en-US': 'See Through2',
            'zh-CN': '通视分析2',
            'fr-FR': '通视分析2'
        }
    }
 
    componentDidMount() {
 
        fetch('./example/ExampleI18nPage.md')
            .then(response => response.text())
            .then(mdText => {
                this.setState({htmlString: window.marked.parse(mdText)});
            });
    }
 
    render() {
        return (
            <div className={"example"}>
                <h3>多语言展示,语言切换,允许增加多语言Key</h3>
                <div className={"map_wrapper"}>
                    <GIS refs={
                        e => {
                            this.mapFunction = e
                        }
                    }
                         mapRef={this}
                         toolbars={this.toolbars}
                         showDefaultLayer={true}
                         i18nObj={this.i18nObj}
                         language={'en-US'}
                    />
                </div>
                <Button onClick={() => {
                    this.mapFunction.updateLanguage('zh-CN');
                }}>中文</Button>
                <Button onClick={() => {
                    this.mapFunction.updateLanguage('en-US');
                }}>英文</Button>
                <Button onClick={() => {
                    this.mapFunction.updateLanguage('fr-FR');
                }}>法语
                </Button>
                <div className={"code_wrapper"}>
                    <div dangerouslySetInnerHTML={{__html: this.state.htmlString}}></div>
                </div>
            </div>
        )
    }
}