Hello everbody, i`m newbie here, how to get marker position after drag ? im using gmpas native. thanks a alot.
lokasisaya.ts
import { Component} from '@angular/core';
import { IonicPage, NavController, NavParams,Platform } from 'ionic-angular';
import { GoogleMaps, GoogleMap, Environment,MyLocationOptions,LocationService,
GoogleMapsEvent, GoogleMapOptions, CameraPosition,
MarkerOptions, Marker, MyLocation } from '@ionic-native/google-maps';
import { Geolocation } from '@ionic-native/geolocation';
/**
* Generated class for the LokasisayaPage page.
*
* See https://ionicframework.com/docs/components/#navigation for more info on
* Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-lokasisaya',
templateUrl: 'lokasisaya.html',
})
export class LokasisayaPage {
map:GoogleMap;
constructor(public navCtrl: NavController, public navParams: NavParams, public platform : Platform,
private geolocation: Geolocation) {
}
ionViewDidLoad() {
this.platform.ready().then(() => {
this.loadMap();
});
}
loadMap(){
let option: MyLocationOptions ={
// true: use gps as much as possible ( use battery usage alot)
// false : use network location or lastKnownLocation
// (save battery usage)
enableHighAccuracy:true
};
LocationService.getMyLocation(option).then((myLocation: MyLocation) => {
let mapOptions: GoogleMapOptions = {
camera: {
target:myLocation.latLng,
zoom: 18,
tilt: 30,
bearing:50
},
controls:{
compass:true,
myLocationButton: true,
zoom:true
},
gestures: {
scroll:true,
tilt:true,
rotate:true,
zoom:true
}
};
// if you want to run your app on browser
Environment.setEnv({
'API_KEY_FOR_BROWSER_RELEASE': 'API URL',
'API_KEY_FOR_BROWSER_DEBUG':''
});
// Create a map
// after the view is ready
// and the native platform is ready.
this.map = GoogleMaps.create('Map',mapOptions);
this.map.addMarker({
title:'Tekan untuk Geser',
icon: 'green',
animation: 'DROP',
position: myLocation.latLng,
draggable: true
}).then((marker: Marker) => {
marker.showInfoWindow();
console.log(myLocation.latLng);
});
});
}
}