Issue
My location with longitude and latitude is working but I need to make a pointer over there, is it possible? I am using NativeScript, Angular2 and NativeScript plugin for Google Maps SDK (nativescript-google-sdk)
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>
Solution
You could use addMarker
method to add Markers in the map. You could review my example below, where have been shown, how to do that.
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);
};
}
Answered By - Nikolay Tsonev
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.