@quieterkali this is my code snippet:
in my AutoCompletePage.ts
import { Component, NgZone } from ‘@angular/core’;
import { IonicPage, NavController, NavParams, ViewController } from ‘ionic-angular’;
import { Geolocation } from ‘@ionic-native/geolocation’;
import { NativeGeocoder, NativeGeocoderReverseResult, NativeGeocoderForwardResult } from ‘@ionic-native/native-geocoder’;
declare var google;
@IonicPage()
@Component({
selector: ‘page-autocompletepage’,
templateUrl: ‘autocompletepage.html’,
})
export class AutocompletepagePage {
// constructor(public navCtrl: NavController, public navParams: NavParams) {
// }
// ionViewDidLoad() {
// console.log(‘ionViewDidLoad AutocompletepagePage’);
// }
autocompleteItems: any = [];
autocomplete;
service = new google.maps.places.AutocompleteService();
constructor (public viewCtrl: ViewController, private zone: NgZone, public navCtrl: NavController,
public navParams: NavParams, public geolocation: Geolocation) {
this.autocompleteItems;
this.autocomplete = {
query: ‘’
};
}
dismiss() {
this.viewCtrl.dismiss();
}
chooseItem(item: any) {
this.viewCtrl.dismiss(item);
}
updateSearch() {
if (this.autocomplete.query == ‘’) {
this.autocompleteItems = [];
return;
}
let me = this;
this.service.getPlacePredictions({ input: this.autocomplete.query, componentRestrictions: {country: ‘PH’} }, function (predictions, status) {
// if (status != google.maps.places.PlacesServiceStatus.OK) {
// alert(status);
// return;
// }
me.autocompleteItems = [];
me.zone.run(function () {
predictions.forEach(function (prediction) {
me.autocompleteItems.push(prediction.description);
});
});
});
}
}
in the registerPage.ts
showAddressModal () {
let modal = this.modalCtrl.create(AutocompletepagePage);
let me = this;
modal.onDidDismiss(data => {
this.place = data;
});
modal.present();
}
im trying to get the lng lat of the result of this, what ever the place the user input: how can i get the long lat of “this.place”?
this.place contains the address returned by the autocompletemodal.