Commit 58f957c3 authored by Priyanka Vivekanand Upadhye's avatar Priyanka Vivekanand Upadhye
Browse files

Merge branch '38-display-calculated-name-of-the-street-on-reservation-and-hire-page' into 'master'

Resolve "Display calculated name of the street on reservation and hire page"

Closes #38

See merge request 92khra1mst/hft_awado_app!23
parents 6d40ac67 abca85a4
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
</ion-row> </ion-row>
<ion-row> <ion-row>
<ion-col>Bike Location</ion-col> <ion-col>Bike Location</ion-col>
<ion-col>{{bikeDetails.address}}</ion-col> <ion-col>{{address}}</ion-col>
</ion-row> </ion-row>
<ion-row *ngIf="!isBikeHired"> <ion-row *ngIf="!isBikeHired">
<ion-col> <ion-col>
......
...@@ -22,6 +22,7 @@ export class HirebikePage implements OnInit { ...@@ -22,6 +22,7 @@ export class HirebikePage implements OnInit {
reservedBike: any = {}; reservedBike: any = {};
bikeDetails: any = {}; bikeDetails: any = {};
address="sample";
isBikeHired=false; isBikeHired=false;
noReservation = true; noReservation = true;
...@@ -82,7 +83,7 @@ export class HirebikePage implements OnInit { ...@@ -82,7 +83,7 @@ export class HirebikePage implements OnInit {
console.log('Bike Details', resp); console.log('Bike Details', resp);
this.bikeDetails = resp.data; this.bikeDetails = resp.data;
this.noReservation = false; this.noReservation = false;
this.reverseGeocode(this.platform, this.bikeDetails.lat, this.bikeDetails.lon);
// display map // display map
setTimeout(() => { setTimeout(() => {
this.loadmap(); this.loadmap();
...@@ -230,7 +231,29 @@ export class HirebikePage implements OnInit { ...@@ -230,7 +231,29 @@ export class HirebikePage implements OnInit {
// Add the marker to the map: // Add the marker to the map:
this.map.addObject(marker); this.map.addObject(marker);
} }
reverseGeocode(platform, lat, lng) {
var prox = lat + ',' + lng + ',56';
var geocoder = platform.getGeocodingService(),
parameters = {
prox: prox,
mode: 'retrieveAddresses',
maxresults: '1',
gen: '9'
};
geocoder.reverseGeocode(parameters, result => {
console.log(result);
var streets = result.Response.View[0].Result[0].Location.Address.Street;
var houseNumber = result.Response.View[0].Result[0].Location.Address.HouseNumber;
var zipcode = result.Response.View[0].Result[0].Location.Address.PostalCode;
this.address = streets;
}, (error) => {
alert(error);
});
}
// Define a callback function to process the routing response: // Define a callback function to process the routing response:
onResult(result) { onResult(result) {
......
...@@ -5,7 +5,7 @@ import { Observable } from 'rxjs'; ...@@ -5,7 +5,7 @@ import { Observable } from 'rxjs';
import { HttpClient, HttpHeaders } from '@angular/common/http'; import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Storage } from '@ionic/storage'; import { Storage } from '@ionic/storage';
import { ToastService } from '../services/toast.service'; import { ToastService } from '../services/toast.service';
import { Router } from '@angular/router';
declare var H: any; declare var H: any;
...@@ -35,6 +35,7 @@ export class HomePage implements OnInit { ...@@ -35,6 +35,7 @@ export class HomePage implements OnInit {
public mapElement: ElementRef; public mapElement: ElementRef;
constructor(private geolocation: Geolocation, constructor(private geolocation: Geolocation,
private router: Router,
public restService: RestService, public restService: RestService,
public httpClient: HttpClient, public httpClient: HttpClient,
private storage: Storage, private storage: Storage,
...@@ -288,6 +289,7 @@ export class HomePage implements OnInit { ...@@ -288,6 +289,7 @@ export class HomePage implements OnInit {
console.log('my data: ', resp); console.log('my data: ', resp);
this.isBikeReserved = true; this.isBikeReserved = true;
this.toastService.showToast("Reservation Successful!"); this.toastService.showToast("Reservation Successful!");
this.router.navigateByUrl('/myreservation');
}, (error) => { }, (error) => {
console.log(error) console.log(error)
this.toastService.showToast("Only one bike may be reserved or rented at a time") this.toastService.showToast("Only one bike may be reserved or rented at a time")
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
</ion-row> </ion-row>
<ion-row> <ion-row>
<ion-col>Bike Location</ion-col> <ion-col>Bike Location</ion-col>
<ion-col>{{bikeDetails.address}}</ion-col> <ion-col>{{address}}</ion-col>
</ion-row> </ion-row>
<ion-row> <ion-row>
<ion-col>Bike Distance</ion-col> <ion-col>Bike Distance</ion-col>
......
...@@ -23,8 +23,8 @@ export class MyreservationPage implements OnInit { ...@@ -23,8 +23,8 @@ export class MyreservationPage implements OnInit {
reservedBike: any = {}; reservedBike: any = {};
bikeDetails: any = {}; bikeDetails: any = {};
isBikeHired=false; isBikeHired = false;
address="sample";
noReservation = true; noReservation = true;
private currentLocation = { lat: 0, lng: 0 }; private currentLocation = { lat: 0, lng: 0 };
...@@ -82,6 +82,7 @@ export class MyreservationPage implements OnInit { ...@@ -82,6 +82,7 @@ export class MyreservationPage implements OnInit {
bikeDetailsApi.subscribe((resp: any) => { bikeDetailsApi.subscribe((resp: any) => {
console.log('Bike Details', resp); console.log('Bike Details', resp);
this.bikeDetails = resp.data; this.bikeDetails = resp.data;
this.reverseGeocode(this.platform, this.bikeDetails.lat, this.bikeDetails.lon);
this.noReservation = false; this.noReservation = false;
// display map // display map
...@@ -183,9 +184,9 @@ export class MyreservationPage implements OnInit { ...@@ -183,9 +184,9 @@ export class MyreservationPage implements OnInit {
// show route on map // show route on map
this.mapRouter.calculateRoute(this.routingParameters, this.onResult.bind(this), this.mapRouter.calculateRoute(this.routingParameters, this.onResult.bind(this),
(error) => { (error) => {
alert(error.message); alert(error.message);
}); });
}, er => { }, er => {
alert('Can not retrieve Location') alert('Can not retrieve Location')
}).catch((error) => { }).catch((error) => {
...@@ -209,6 +210,29 @@ export class MyreservationPage implements OnInit { ...@@ -209,6 +210,29 @@ export class MyreservationPage implements OnInit {
// Add the marker to the map: // Add the marker to the map:
this.map.addObject(marker); this.map.addObject(marker);
} }
reverseGeocode(platform, lat, lng) {
var prox = lat + ',' + lng + ',56';
var geocoder = platform.getGeocodingService(),
parameters = {
prox: prox,
mode: 'retrieveAddresses',
maxresults: '1',
gen: '9'
};
geocoder.reverseGeocode(parameters, result => {
console.log(result);
var streets = result.Response.View[0].Result[0].Location.Address.Street;
var houseNumber = result.Response.View[0].Result[0].Location.Address.HouseNumber;
var zipcode = result.Response.View[0].Result[0].Location.Address.PostalCode;
this.address = streets;
}, (error) => {
alert(error);
});
}
// Define a callback function to process the routing response: // Define a callback function to process the routing response:
...@@ -251,7 +275,7 @@ export class MyreservationPage implements OnInit { ...@@ -251,7 +275,7 @@ export class MyreservationPage implements OnInit {
lineWidth: 6, lineWidth: 6,
strokeColor: 'rgba(0, 72, 255, 0.8)', strokeColor: 'rgba(0, 72, 255, 0.8)',
lineDash: [0, 2] lineDash: [0, 2]
} }
}); });
// Add the route polyline and the two markers to the map: // Add the route polyline and the two markers to the map:
...@@ -262,10 +286,11 @@ export class MyreservationPage implements OnInit { ...@@ -262,10 +286,11 @@ export class MyreservationPage implements OnInit {
//this.map.setZoom(this.map.getZoom() - 4.3, true); //this.map.setZoom(this.map.getZoom() - 4.3, true);
} }
}; };
hireBike() { hireBike() {
if (this.isBikeHired) if (this.isBikeHired)
this.toastService.showToast("You already Hired this bike"); this.toastService.showToast("You already Hired this bike");
else else
this.router.navigateByUrl('/hirebike'); this.router.navigateByUrl('/hirebike');
} }
} }
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