Commit c6d6c045 by Alen Jose

Merge branch 'alen' into 'master'

july-26 See merge request alen/CMC_revamp!21
parents 1e023ff5 c6190ae6
...@@ -24,6 +24,7 @@ export class MapPage { ...@@ -24,6 +24,7 @@ export class MapPage {
count: number = 0 count: number = 0
markers: any; markers: any;
tempLast: any; tempLast: any;
userMarkers: any;
constructor(public navCtrl: NavController, public navParams: NavParams, private data: dataService, private geolocation: Geolocation, private myservice: Myservice) { constructor(public navCtrl: NavController, public navParams: NavParams, private data: dataService, private geolocation: Geolocation, private myservice: Myservice) {
} }
...@@ -80,21 +81,28 @@ export class MapPage { ...@@ -80,21 +81,28 @@ export class MapPage {
This.markers.setMap(null); This.markers.setMap(null);
} }
var marker = new google.maps.Marker({ if (This.userMarkers)
This.userMarkers.setMap(null);
var marker = new google.maps.Marker({//driver marker
position: driverLoc, position: driverLoc,
map: This.map, map: This.map,
icon: dimage icon: dimage
}); });
var markerUser = new google.maps.Marker({//user marker
position: pickLoc,
map: This.map
});
This.markers = marker This.markers = marker
This.userMarkers = markerUser
var cur = driverLoc var cur = driverLoc
var lastPosn = new google.maps.LatLng(This.lastPos[0].lat, This.lastPos[0].lng) var lastPosn = new google.maps.LatLng(This.lastPos[0].lat, This.lastPos[0].lng)
var heading = google.maps.geometry.spherical.computeHeading(lastPosn, cur) var heading = google.maps.geometry.spherical.computeHeading(lastPosn, cur)
dimage.rotation = heading; dimage.rotation = heading;
marker.setIcon(dimage); marker.setIcon(dimage);
////
This.calculateAndDisplayRoute(directionsService, This.directionsDisplay, pickLoc, driverLoc); This.calculateAndDisplayRoute(directionsService, This.directionsDisplay, pickLoc, driverLoc);
} }
...@@ -113,9 +121,9 @@ export class MapPage { ...@@ -113,9 +121,9 @@ export class MapPage {
zoom: 15, zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP mapTypeId: google.maps.MapTypeId.ROADMAP
} }
this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions); this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
this.directionsDisplay = new google.maps.DirectionsRenderer({ this.directionsDisplay = new google.maps.DirectionsRenderer({
map: this.map, map: this.map,
preserveViewport: true preserveViewport: true
...@@ -151,7 +159,7 @@ export class MapPage { ...@@ -151,7 +159,7 @@ export class MapPage {
.filter((p) => p.coords !== undefined) //Filter Out Errors .filter((p) => p.coords !== undefined) //Filter Out Errors
.subscribe(position => { .subscribe(position => {
if (this.count > 0){ if (this.count > 0) {
This.lastPos[0].lat = this.tempLast[0] This.lastPos[0].lat = this.tempLast[0]
This.lastPos[0].lng = this.tempLast[1] This.lastPos[0].lng = this.tempLast[1]
} }
...@@ -180,12 +188,17 @@ export class MapPage { ...@@ -180,12 +188,17 @@ export class MapPage {
This.markers.setMap(null); This.markers.setMap(null);
} }
var marker = new google.maps.Marker({ var marker = new google.maps.Marker({//user marker
position: myLoc, position: myLoc,
map: This.map, map: This.map,
icon: dimage icon: dimage
}); });
new google.maps.Marker({//destination marker
position: destLoc,
map: This.map
});
This.markers = marker This.markers = marker
var cur = new google.maps.LatLng(position.coords.latitude, position.coords.longitude) var cur = new google.maps.LatLng(position.coords.latitude, position.coords.longitude)
...@@ -194,22 +207,22 @@ export class MapPage { ...@@ -194,22 +207,22 @@ export class MapPage {
dimage.rotation = heading; dimage.rotation = heading;
marker.setIcon(dimage); marker.setIcon(dimage);
if (google.maps.geometry.spherical.computeDistanceBetween(myLoc, destLoc) < 50){ if (google.maps.geometry.spherical.computeDistanceBetween(myLoc, destLoc) < 50) {
var locRef = firebase.database().ref().child('/drivers/'); var locRef = firebase.database().ref().child('/drivers/');
locRef.orderByChild("id").equalTo((This.driver.driverId)).on("value", function (snapshot) { locRef.orderByChild("id").equalTo((This.driver.driverId)).on("value", function (snapshot) {
var res_arr = [] var res_arr = []
res_arr = (<any>Object).entries(snapshot.val()).map(e => Object.assign(e[1], { key: e[0] })); res_arr = (<any>Object).entries(snapshot.val()).map(e => Object.assign(e[1], { key: e[0] }));
console.log(res_arr[0]) console.log(res_arr[0])
if (res_arr[0].started == false) { if (res_arr[0].started == false) {
This.pushed++ This.pushed++
console.log(This.pushed) console.log(This.pushed)
This.myservice.show_loader() This.myservice.show_loader()
locRef.off(); locRef.off();
if (This.pushed == 1) if (This.pushed == 1)
This.navCtrl.setRoot('PaymentPage') This.navCtrl.setRoot('PaymentPage')
} }
}) })
} }
This.calculateAndDisplayRoute(directionsService, This.directionsDisplay, myLoc, destLoc); This.calculateAndDisplayRoute(directionsService, This.directionsDisplay, myLoc, destLoc);
}); });
......
...@@ -90,6 +90,9 @@ export class PaymentPage { ...@@ -90,6 +90,9 @@ export class PaymentPage {
console.log(this.ride) console.log(this.ride)
console.log(this.loc) console.log(this.loc)
} }
else{
this.myservice.show_alert('',resp.message)
}
}) })
}) })
} }
...@@ -107,5 +110,4 @@ export class PaymentPage { ...@@ -107,5 +110,4 @@ export class PaymentPage {
close() { close() {
this.navCtrl.push('RattingPage', { driver: this.driver }) this.navCtrl.push('RattingPage', { driver: this.driver })
} }
} }
...@@ -38,7 +38,6 @@ export class RattingPage { ...@@ -38,7 +38,6 @@ export class RattingPage {
this.myservice.show_loader(); this.myservice.show_loader();
var book = this.comData.getbookingData() var book = this.comData.getbookingData()
var data = { 'rating': this.rate, 'username': this.local.id, 'driver_id': this.driver.driverId, 'booking_id': book.bookingid } var data = { 'rating': this.rate, 'username': this.local.id, 'driver_id': this.driver.driverId, 'booking_id': book.bookingid }
console.log(data)
this.myservice.load_post(data, 'setRating').subscribe(response => { this.myservice.load_post(data, 'setRating').subscribe(response => {
this.myservice.hide_loader() this.myservice.hide_loader()
......
...@@ -23,7 +23,7 @@ export class RidedetailPage { ...@@ -23,7 +23,7 @@ export class RidedetailPage {
driver: any; driver: any;
bkid: any; bkid: any;
drivers = [] drivers = []
temp:boolean = false; temp: boolean = false;
constructor(public navCtrl: NavController, public navParams: NavParams, private data: dataService, private zone: NgZone, private myservice: Myservice, private storage: Storage, public platform: Platform, public loadingCtrl: LoadingController, private alertCtrl: AlertController) { constructor(public navCtrl: NavController, public navParams: NavParams, private data: dataService, private zone: NgZone, private myservice: Myservice, private storage: Storage, public platform: Platform, public loadingCtrl: LoadingController, private alertCtrl: AlertController) {
} }
...@@ -117,7 +117,7 @@ export class RidedetailPage { ...@@ -117,7 +117,7 @@ export class RidedetailPage {
This.temp = true This.temp = true
} }
else { else {
This.myservice.show_alert('Failed', 'Please try again') This.myservice.show_alert('Failed', response.message)
This.navCtrl.pop() This.navCtrl.pop()
} }
}) })
...@@ -153,6 +153,8 @@ export class RidedetailPage { ...@@ -153,6 +153,8 @@ export class RidedetailPage {
This.myservice.load_post({ taxiType: This.book.carDetails.car_type, driversid: This.drivers, bookid: This.bkid }, 'driverPush').subscribe(data => { This.myservice.load_post({ taxiType: This.book.carDetails.car_type, driversid: This.drivers, bookid: This.bkid }, 'driverPush').subscribe(data => {
if (data.status == 'success') if (data.status == 'success')
This.checkResp(); This.checkResp();
else
This.myservice.show_alert('', data.message)
}) })
}, 500); }, 500);
} }
...@@ -173,6 +175,8 @@ export class RidedetailPage { ...@@ -173,6 +175,8 @@ export class RidedetailPage {
clearInterval(intrvl) clearInterval(intrvl)
This.loader.dismissAll(); This.loader.dismissAll();
} }
else
This.myservice.show_alert('',resp.message)
}) })
if (This.count == 12) { if (This.count == 12) {
clearInterval(intrvl) clearInterval(intrvl)
......
...@@ -25,6 +25,8 @@ export class RidenowPage { ...@@ -25,6 +25,8 @@ export class RidenowPage {
if(response.status == 'success'){ if(response.status == 'success'){
this.rates = response.data this.rates = response.data
} }
else
this.myservice.show_alert('',response.message)
}) })
var origin = new google.maps.LatLng(this.details.pickLat, this.details.pickLng) var origin = new google.maps.LatLng(this.details.pickLat, this.details.pickLng)
......
...@@ -82,6 +82,8 @@ export class RidesummaryPage { ...@@ -82,6 +82,8 @@ export class RidesummaryPage {
} }
} }
} }
else
this.myservice.show_alert('',resp.message)
}) })
} }
......
...@@ -26,6 +26,8 @@ export class SearchridePage { ...@@ -26,6 +26,8 @@ export class SearchridePage {
if(response.status == 'success'){ if(response.status == 'success'){
this.searches = response.data this.searches = response.data
} }
else
this.myservice.show_alert('',response.message)
}) })
} }
}) })
......
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