Commit 52da2c34 authored by Manideep2897's avatar Manideep2897 Committed by GitHub

Merge pull request #1 from KLGLUG/maps

continuous tracking
parents 42dda494 3f17eba3
......@@ -17,6 +17,7 @@
<div padding>
<button block ion-button style="padding:0px; width: 100%;" medium (click)="mapUser()">LOCATE ME</button>
</div>
<agm-map [latitude]="location?.coords.latitude" [streetViewControl]="true" [longitude]="location?.coords.longitude" [mapTypeId]="'hybrid'" [zoom]="15">
......
......@@ -2,6 +2,9 @@ import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams ,Platform} from 'ionic-angular';
import { AgmCoreModule } from '@agm/core';
import { Geolocation } from '@ionic-native/geolocation';
import { HttpClient, HttpHeaders } from '@angular/common/http';
/**
* Generated class for the MapsPage page.
......@@ -16,10 +19,11 @@ import { Geolocation } from '@ionic-native/geolocation';
templateUrl: 'maps.html',
})
export class MapsPage {
baseURI : string = "http://localhost/mani/newfile.php";
coords:any;
hei:any;
location:any;
firebase:any;
constructor(public navCtrl: NavController, private geolocation: Geolocation,public navParams: NavParams,public platform:Platform) {
constructor(public navCtrl: NavController,public http: HttpClient, private geolocation: Geolocation,public navParams: NavParams,public platform:Platform) {
}
options={
colorl:'#ASDF96',
......@@ -28,9 +32,31 @@ export class MapsPage {
fontweightl:'bold',
textl:'B',
}
entry(latitude:string,longitude:string)
{
let headers : any = new HttpHeaders({ 'Content-Type': 'application/json' }),
options : any = { "key" : "create", "latitude" :latitude,"longitude" : longitude},
url : any = this.baseURI;
this.http
.post(url, JSON.stringify(options), headers)
.subscribe((data: any) =>
{
// If the request was successful notify the user
console.log(`Congratulations the technology: ${latitude} was successfully updated`);
},
(error : any) =>
{
console.log({error});
});
}
mapUser(): void
{
this.platform.ready().then(()=>{
......@@ -38,16 +64,23 @@ export class MapsPage {
this.geolocation.getCurrentPosition(options).then((location) => {
console.log('Fetched the location successfully',location);
this.location=location;
let latitude : string=this.location.coords.latitude,
longitude : string=this.location.coords.longitude;
setInterval(()=>{
this.entry(latitude,longitude);
}, 5000)
}).catch((error) => {
console.log('Error getting location', error);
//let latitude : number=this.location.coords.latitude,
//longitude : number=this.location.coords.longitude;
//this.entry(latitude,longitude);
});
});
//let latitude : number=this.location.coords.latitude,
//longitude : number=this.location.coords.longitude;
}
ionViewDidLoad() {
console.log('ionViewDidLoad MapsPage');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment