我正在尝试将 Google Maps 插件用于 Nativescript ( https://github.com/dapriett/nativescript-google-maps-sdk ) 和 Angular 2 和 {N}-Angular 路由器。我让它只在 Nativescript 中工作,但是一旦我添加了 Angular 2 和路由器,我就无法让地图显示在 UI 中。
由于<Page>标签没有进入 Angular2 {N} 组件模板,我不能使用xmlns:maps="nativescript-google-maps-sdk"命名空间<Page>来实例化<maps:mapView>
{N} 组件基础知识页面提供了一些指导,但它在我尝试过的方式中不起作用:https : //docs.nativescript.org/ui/ui-with-xml#user-interface-components
关于这样做的正确方法的任何想法是?
app.component.ts
import {Component} from "angular2/core";
import {RouteConfig} from "angular2/router";
import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "nativescript-angular/router";
import {HomeComponent} from "./pages/home/home.component";
@Component({
selector: "app-main",
directives: [NS_ROUTER_DIRECTIVES],
providers: [NS_ROUTER_PROVIDERS],
template: "<page-router-outlet ></page-router-outlet>"
})
@RouteConfig([
{ path: "/home", component: HomeComponent, as: "Home", useAsDefault: true },
])
export …Run Code Online (Sandbox Code Playgroud)