0

我正在尝试使用需要上下文来实例化 UI 对象的本机映射库,我该如何传递它?

native 函数是 android.view.View 的扩展,它需要的参数是一个 Context。

参考:https://developers.arcgis.com/android/latest/api-reference/reference/com/esri/arcgisruntime/mapping/view/MapView.html#MapView(android.content.Context)

例子.vue:

<template>
    <Page class="page">
        <StackLayout>
            <Placeholder @creatingView="creatingView"/>
         </StackLayout>
    </Page>
</template>

<script>
    export default {
        methods: {
            creatingView(args){
                //This is where I need the context as a parameter
                const nativeView = new com.esri.arcgisruntime.mapping.view.MapView(this.context);
                args.view = nativeView;                    
            }
        }
    };
</script>
4

2 回答 2

0

您可以从 createView 事件参数中获取当前的 android 上下文。

methods: {
       creatingView(args){
           const nativeView = new com.esri.arcgisruntime.mapping.view.MapView(args.context);
           args.view = nativeView;                    
       }
}
于 2019-03-24T14:35:05.023 回答
0

无论您使用什么风格/框架,您都可以使用应用程序上下文,

import * as application from "application";

const context = application.android.context;
于 2018-11-19T20:19:17.017 回答