1
i have an application that displays on the screen the latitude and longitude wanted to know how to record this data in firebase
my home code is like this
import { Component } from '@angular/core';
import { Navcontroller, Platform } from 'Ionic-angular'; import { Geolocation, Geolocationoptions, Geoposition} from '@Ionic-Native/Geolocation';
@Component({ selector: 'page-home', templateUrl: 'home.html' }) export class Homepage{
geoposition: Geoposition
geolocationOptions: GeolocationOptions
constructor(private platform: Platform,
private geolocation: Geolocation,
public navCtrl: NavController){
}
async getGeolocation(){
await this.platform.ready();
try {
this.geolocationOptions = {
maximumAge: 1000,
timeout: 1000,
enableHighAccuracy: true
}
this.geoposition = await this.geolocation.getCurrentPosition(this.geolocationOptions);
}
catch(e){
console.error(e)
}
}
}
the html that displays the data on the screen
<ion-list>
<ion-item>
Accurary: {{geoposition.coords.accuracy}}
</ion-item>
<ion-item>
Latitude: {{geoposition.coords.latitude}}
</ion-item>
<ion-item>
Longitude: {{geoposition.coords.longitude}}
</ion-item>
<ion-item>
Timestamp:{{geoposition.timestamp |date}}
</ion-item>