react-native-mobilex 开发文档
    Preparing search index...

    Type Alias ControllerBase

    Controller 基础生命周期和 WebView 消息入口。

    这些方法由 createController 创建,负责连接 WebView 中运行的 MobileX Web SDK。 完成初始化后,才能调用 map、scene 等由 Web SDK 注册的模块方法。

    type ControllerBase = {
        destroy: () => Promise<void>;
        getLogLevel: () => Promise<LogLevel>;
        handleMessage: (messageStr: string) => void;
        init: (
            container?: string,
            option?: Partial<ServerOption> & Partial<ControllerOption>,
        ) => Promise<void>;
        setLogLevel: (level: LogLevel) => Promise<void>;
    }
    Index

    Properties

    destroy: () => Promise<void>

    销毁当前 client 对应的 Web SDK server 实例。

    销毁后需要重新调用 ControllerBase.init 才能继续使用模块方法。

    getLogLevel: () => Promise<LogLevel>

    获取当前 web 端日志输出阈值,默认 'warn'

    handleMessage: (messageStr: string) => void

    处理 WebView 发回的消息字符串。

    RN 或宿主侧收到 WebView postMessage 后应把原始字符串传入此方法,由 client 分发给模块调用和事件监听。

    init: (
        container?: string,
        option?: Partial<ServerOption> & Partial<ControllerOption>,
    ) => Promise<void>

    初始化 client 对象并创建对应的 Web SDK server 实例。

    初始化过程会根据 option.mode 选择二维地图或三维场景能力,并把 Web SDK 注册的模块方法绑定为异步接口。 重复调用不会重新初始化。

    Type declaration

      • (
            container?: string,
            option?: Partial<ServerOption> & Partial<ControllerOption>,
        ): Promise<void>
      • Parameters

        • Optionalcontainer: string

          Web 页面中承载地图或场景的 DOM 容器 ID,默认值为 Container。

        • Optionaloption: Partial<ServerOption> & Partial<ControllerOption>

          初始化参数,可同时传入通用 client 参数和三维 server 参数。

        Returns Promise<void>

        初始化完成后 resolve;初始化失败时透出 Web SDK 或消息桥接抛出的错误。

    setLogLevel: (level: LogLevel) => Promise<void>

    设置 web 端日志输出阈值,默认 'warn'