2016-07-28 10 views
0

経度と緯度のある私の位置は機能していますが、そこにポインタを置く必要がありますか?私はGoogleマップSDK(nativescript-グーグル-SDK)のためNativeScriptとAngular2を使用してMapViewにポインタを作成するにはどうすればよいですか?

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> 

map_without_pointer

をNativeScript、Angular2とNativeScriptプラグインを使用しています

map_with_pointer

答えて

0

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); 
    }; 
} 
+0

感謝のニコライ。私はマーカーのアイコンも変更しました... 'var image = new ImageModule.Image(); var imageSource = imageSourceModule.fromResource( "icon"); image.imageSource = imageSource; marker.icon = image; ' – Fernanda

関連する問題