我的经度和纬度位置正常,但我需要在那里制作指针,这可能吗?我正在为Google Maps SDK(nativescript-google-sdk)使用NativeScript,Angular2和NativeScript插件
file.ts
import { registerElement } from 'nativescript-angular/element-registry';
registerElement("MapView", () => require("nativescript-google-maps-sdk").MapView);
file.xml
<MapView [latitude]="configService.unitPreview.latitude" [longitude]="configService.unitPreview.longitude"
zoom="17" bearing="0"
tilt="0" (mapReady)="OnMapReady"
(markerSelect)="onMarkerSelect"
(cameraChanged)="onCameraChanged">
</MapView>
答案 0 :(得分:1)
您可以使用addMarker
方法在地图中添加标记。您可以查看下面的示例,其中显示了如何执行此操作。
app,component.html
<GridLayout>
<MapView (mapReady)="onMapReady($event)" ></MapView>
</GridLayout>
app.com-ponent.ts
import {Component, ElementRef, ViewChild} from '@angular/core';
var mapsModule = require("nativescript-google-maps-sdk");
@Component({
selector: "my-app",
templateUrl: "app.component.html",
})
export class AppComponent {
@ViewChild("MapView") mapView: ElementRef;
constructor(){
}
//Map events
onMapReady = (event) => {
console.log("Map Ready");
var map =event.object;
var marker = new mapsModule.Marker();
marker.position = mapsModule.Position.positionFromLatLng(48.87, 2.35);
marker.title = "Sydney";
marker.snippet = "Australia";
marker.userData = { index : 1};
map.addMarker(marker);
};
}
答案 1 :(得分:0)
有可能像图像一样显示真实的流量吗?