Google maps 如何使用nativescript google maps sdk和Angular 2添加地图标记
我正在尝试为NativeScript使用谷歌地图插件。我没有显示地图,但我在文档中没有看到任何关于添加带有角度2的标记的内容。有人知道如何将标记添加到具有角度2个组件的地图上吗?自述文件: /app/map-example.component.html 从这里的自述文件: /app/map-example.component.htmlGoogle maps 如何使用nativescript google maps sdk和Angular 2添加地图标记,google-maps,angular,nativescript,Google Maps,Angular,Nativescript,我正在尝试为NativeScript使用谷歌地图插件。我没有显示地图,但我在文档中没有看到任何关于添加带有角度2的标记的内容。有人知道如何将标记添加到具有角度2个组件的地图上吗?自述文件: /app/map-example.component.html 从这里的自述文件: /app/map-example.component.html 我看到了,但它在Angular 2模板中不起作用。这是一种普通的JavaScript方法。有人知道角度2的方法吗?这也是角度2的方法。它们非常相似。我看到了,但在
我看到了,但它在Angular 2模板中不起作用。这是一种普通的JavaScript方法。有人知道角度2的方法吗?这也是角度2的方法。它们非常相似。我看到了,但在Angular 2模板中不起作用。这是一种普通的JavaScript方法。有人知道角度2的方法吗?这也是角度2的方法。它们非常相似。愿你平安试试这个:愿你平安试试这个:
<GridLayout>
<MapView (mapReady)="onMapReady($event)"></MapView>
</GridLayout>
import {Component, ElementRef, ViewChild} from '@angular/core';
import { MapView, Position, Marker } from 'nativescript-google-maps-sdk';
@Component({
selector: 'map-example-component',
templateUrl: 'map-example.component.html'
})
export class MapExampleComponent {
private mapView: MapView;
//Map events
private onMapReady(args): void {
this.mapView = args.object;
this.addMarker();
}
private addMarker(): void {
console.log("Setting a marker...");
var marker = new Marker();
marker.position = Position.positionFromLatLng(-33.86, 151.20);
marker.title = "Sydney";
marker.snippet = "Australia";
marker.userData = { index : 1};
this.mapView.addMarker(marker);
}
}