Przeglądaj źródła

Added geolocation config, added functionality to get user coordinates, added trails page with button to get coords to console

Kris Blassingame 6 lat temu
rodzic
commit
8c80eab5ff

+ 3
- 3
frontEnd/config.xml Wyświetl plik

@@ -81,10 +81,10 @@
81 81
     <plugin name="cordova-plugin-splashscreen" spec="5.0.2" />
82 82
     <plugin name="cordova-plugin-ionic-webview" spec="1.1.19" />
83 83
     <plugin name="cordova-plugin-ionic-keyboard" spec="2.0.5" />
84
+    <edit-config file="*-Info.plist" mode="merge" target="NSLocationWhenInUseUsageDescription">
85
+        <string>We want your location! Best regards NSA</string>
86
+    </edit-config>
84 87
     <plugin name="cordova-plugin-geolocation" spec="^4.0.1">
85 88
         <variable name="GEOLOCATION_USAGE_DESCRIPTION" value="To locate you" />
86 89
     </plugin>
87
-    <edit-config file="*-Info.plist" mode="merge" target="NSLocationWhenInUseUsageDescription">
88
-   <string>We want your location! Best regards NSA</string>
89
-</edit-config>
90 90
 </widget>

+ 7
- 3
frontEnd/src/app/app.module.ts Wyświetl plik

@@ -12,7 +12,8 @@ import { MainMenuPage } from '../pages/main-menu/main-menu';
12 12
 import { HttpClientModule } from '@angular/common/http';
13 13
 import { GoogleMapPage } from '../pages/googleMap/googleMap';
14 14
 import { RestProvider } from '../providers/rest/rest';
15
-
15
+import {Geolocation} from '@ionic-native/geolocation';
16
+import { TrailsPage } from '../pages/trails/trails';
16 17
 
17 18
 @NgModule({
18 19
   declarations: [
@@ -21,7 +22,8 @@ import { RestProvider } from '../providers/rest/rest';
21 22
     GoogleMapComponent,
22 23
     MainMenuPage,
23 24
     RegisterPage,
24
-    GoogleMapPage
25
+    GoogleMapPage,
26
+    TrailsPage
25 27
     
26 28
   ],
27 29
   imports: [
@@ -36,12 +38,14 @@ import { RestProvider } from '../providers/rest/rest';
36 38
     GoogleMapComponent,
37 39
     MainMenuPage,
38 40
     RegisterPage,
39
-    GoogleMapPage
41
+    GoogleMapPage,
42
+    TrailsPage
40 43
   ],
41 44
   providers: [
42 45
     StatusBar,
43 46
     SplashScreen,
44 47
     RestProvider,
48
+    Geolocation,
45 49
     {provide: ErrorHandler, useClass: IonicErrorHandler}
46 50
   ]
47 51
 })

+ 1
- 1
frontEnd/src/pages/main-menu/main-menu.html Wyświetl plik

@@ -11,7 +11,7 @@
11 11
   <ion-grid class="mainMenuButtons">
12 12
     <ion-row>
13 13
       <ion-col col-6 text-center>
14
-        <button ion-button>
14
+        <button ion-button (click)="trails()">
15 15
           <ion-icon name="bicycle">
16 16
             <br>Trails</ion-icon>
17 17
         </button>

+ 5
- 7
frontEnd/src/pages/main-menu/main-menu.ts Wyświetl plik

@@ -1,13 +1,7 @@
1 1
 import { Component } from '@angular/core';
2 2
 import { IonicPage, NavController, NavParams } from 'ionic-angular';
3 3
 import { GoogleMapComponent } from '../../components/google-map/google-map';
4
-
5
-/**
6
- * Generated class for the MainMenuPage page.
7
- *
8
- * See https://ionicframework.com/docs/components/#navigation for more info on
9
- * Ionic pages and navigation.
10
- */
4
+import { TrailsPage } from '../trails/trails';
11 5
 
12 6
 @IonicPage()
13 7
 @Component({
@@ -27,4 +21,8 @@ export class MainMenuPage {
27 21
     this.navCtrl.push(GoogleMapComponent);
28 22
   }
29 23
 
24
+  trails(){
25
+    this.navCtrl.push(TrailsPage);
26
+  }
27
+
30 28
 }

+ 18
- 0
frontEnd/src/pages/trails/trails.html Wyświetl plik

@@ -0,0 +1,18 @@
1
+<!--
2
+  Generated template for the TrailsPage page.
3
+
4
+  See http://ionicframework.com/docs/components/#navigation for more info on
5
+  Ionic pages and navigation.
6
+-->
7
+<ion-header>
8
+
9
+  <ion-navbar>
10
+    <ion-title>Trails</ion-title>
11
+  </ion-navbar>
12
+
13
+</ion-header>
14
+
15
+
16
+<ion-content padding>
17
+<button ion-button (click)="getLocation()">Click this for location</button>
18
+</ion-content>

+ 13
- 0
frontEnd/src/pages/trails/trails.module.ts Wyświetl plik

@@ -0,0 +1,13 @@
1
+import { NgModule } from '@angular/core';
2
+import { IonicPageModule } from 'ionic-angular';
3
+import { TrailsPage } from './trails';
4
+
5
+@NgModule({
6
+  declarations: [
7
+    TrailsPage,
8
+  ],
9
+  imports: [
10
+    IonicPageModule.forChild(TrailsPage),
11
+  ],
12
+})
13
+export class TrailsPageModule {}

+ 3
- 0
frontEnd/src/pages/trails/trails.scss Wyświetl plik

@@ -0,0 +1,3 @@
1
+page-trails {
2
+
3
+}

+ 32
- 0
frontEnd/src/pages/trails/trails.ts Wyświetl plik

@@ -0,0 +1,32 @@
1
+import { Component } from '@angular/core';
2
+import { IonicPage, NavController, NavParams } from 'ionic-angular';
3
+import {Geolocation} from '@ionic-native/geolocation'
4
+
5
+
6
+@IonicPage()
7
+@Component({
8
+  selector: 'page-trails',
9
+  templateUrl: 'trails.html',
10
+})
11
+export class TrailsPage {
12
+
13
+  constructor(public navCtrl: NavController, public navParams: NavParams, private _geoLoc: Geolocation) {
14
+  }
15
+
16
+  ionViewDidLoad() {
17
+    console.log('ionViewDidLoad TrailsPage');
18
+  }
19
+  ngAfterViewInit() {
20
+    this.getLocation().then(res => {
21
+      console.log(res.coords.latitude)
22
+      console.log(res.coords.longitude)
23
+    }).catch(err => {
24
+      console.log(err);
25
+    });
26
+  }
27
+
28
+  getLocation(){
29
+    return this._geoLoc.getCurrentPosition();
30
+  }
31
+
32
+}