Commit e8a8a769 by Adarsh K

Merge branch 'adarsh' into 'master'

Adarsh See merge request !108
parents 09414565 d9cdf58f
......@@ -57,6 +57,7 @@ export class ChangeaddressPage implements OnInit {
this.lat = '';
this.lng = '';
this.type = 0;
this.zoom = 16;
const users = this.service.get('user').then(data => {
if (data) {
data = JSON.parse(data);
......@@ -100,7 +101,7 @@ export class ChangeaddressPage implements OnInit {
navigator.geolocation.getCurrentPosition(position => {
this.latitude = position.coords.latitude;
this.longitude = position.coords.longitude;
this.zoom = 8;
this.zoom = 16;
this.getAddress(this.latitude, this.longitude);
});
}
......@@ -116,7 +117,7 @@ export class ChangeaddressPage implements OnInit {
console.log(e);
this.newCenterLat = e.lat;
this.newCenterLng = e.lng;
this.getAddress(this.newCenterLat, this.newCenterLng);
// this.getAddress(this.newCenterLat, this.newCenterLng);
}
markerDragEnd($event: MouseEvent) {
......
......@@ -195,9 +195,8 @@
</label>
</div>
<div>
<p>
{{address.building}}, <span
*ngIf="address.landmark && address.landmark!==''">{{address.landmark}},</span>
<p>{{address.building}}<span *ngIf="address.landmark && address.landmark!==''">,
{{address.landmark}}</span>
<!-- {{address.address}} -->
</p>
</div>
......
......@@ -78,13 +78,15 @@ export class HomePage implements OnInit {
this.custId = data.uid;
this.addressService.addList(data.uid);
this.subjectService.getAddressStateData().subscribe((state) => {
console.log(state);
if (state !== null) {
this.addressService.defaultAddress(data.uid).then((addressData) => {
console.log(this.addressService.defaultAdd);
const latLng = this.addressService.defaultAdd.latLng;
// tslint:disable-next-line:max-line-length
this.centerService.getNearBy(latLng.latitude, latLng.longitude, this.service.distance);
this.getAddress(latLng.latitude, latLng.longitude);
this.address = this.addressService.defaultAdd.building;
// this.getAddress(latLng.latitude, latLng.longitude);
});
}
});
......@@ -107,7 +109,7 @@ export class HomePage implements OnInit {
const This = this;
setTimeout(() => {
This.mapsAPILoader.load().then(() => {
This.setCurrentLocation();
// This.setCurrentLocation();
This.geoCoder = new google.maps.Geocoder();
const autocomplete = new google.maps.places.Autocomplete(This.searchElementRef.nativeElement, {
types: ['address']
......@@ -170,47 +172,29 @@ export class HomePage implements OnInit {
setDefault(address: any) {
this.loader = true;
if (address.addressId !== '') {
this.addressService
.setDefaultAddress(address.addressId, this.custId)
.then(() => {
this.address = address.building;
this.lat = address.latLng.latitude;
this.lng = address.latLng.longitude;
console.log(address.latLng);
this.centerService.getNearBy(
address.latLng.latitude,
address.latLng.longitude,
this.service.distance
);
this.loader = false;
})
.catch(err => {
this.loader = false;
this.service.showToast(
'Something went wrong please try again!',
'top',
'my-error',
1000
);
});
} else {
const This = this;
This.address = address.building;
console.log(address);
this.lat = address.latLng.latitude;
this.lng = address.latLng.longitude;
console.log(address.latLng);
this.centerService.getNearBy(
address.latLng.latitude,
address.latLng.longitude,
this.service.distance
);
setTimeout(() => {
This.loader = false;
}, 1000);
}
this.addressService
.setDefaultAddress(address.addressId, this.custId)
.then(() => {
this.address = address.building;
this.lat = address.latLng.latitude;
this.lng = address.latLng.longitude;
console.log(address.latLng);
this.centerService.getNearBy(
address.latLng.latitude,
address.latLng.longitude,
this.service.distance
);
this.loader = false;
})
.catch(err => {
this.loader = false;
this.service.showToast(
'Something went wrong please try again!',
'top',
'my-error',
1000
);
});
}
clickSearch() {
......
......@@ -49,6 +49,8 @@ export class NearbyPage implements OnInit {
public service: ServiceService,
public authService: AuthService
) {
this.latitude = 0;
this.longitude = 0;
this.successState = false;
this.type = 0;
const users = this.service.get('user').then(data => {
......@@ -90,11 +92,7 @@ export class NearbyPage implements OnInit {
// google maps zoom level
private setCurrentLocation() {
console.log('map-called');
if ('geolocation' in navigator) {
console.log(navigator);
/* this.latitude = -33.87276;
this.longitude = 151.20534; */
this.zoom = 16;
this.getAddress(this.latitude, this.longitude);
navigator.geolocation.getCurrentPosition(position => {
......@@ -138,8 +136,14 @@ export class NearbyPage implements OnInit {
mapReady(map) {
console.log('called');
map.addListener('dragend', () => {
console.log(this.searchElementRef.nativeElement.value);
console.log(this.newCenterLat, this.newCenterLng);
this.getAddress(this.newCenterLat, this.newCenterLng);
const This = this;
setTimeout(() => {
This.searchElementRef.nativeElement.value = this.address;
}, 500);
});
}
centerChange(e) {
......
......@@ -107,16 +107,18 @@
<div class="delivery-wrap">
<h4 class="floatLeft">DELIVERY</h4>
<span class="floatRight" *ngIf="cancelDelivery > 0 && data.orderStatus != 0 && data.orderStatus != 8"><img
<span class="floatRight"
*ngIf="cancelDelivery > 0 && data.orderStatus != 0 && data.orderStatus != 8"><img
class="ng-tns-c3-0" src="../../assets/edit.png" (click)="changeAddress(data.orderId)" /></span>
<div class="clear"></div>
</div>
<h5 *ngIf="data.deliveryAddress">
{{data.deliveryAddress.addressType}}
<!-- ,<br />{{data.deliveryAddress.address}} -->,
<br /> {{data.deliveryAddress.building}}<span *ngIf="data.deliveryAddress.landmark && data.deliveryAddress.landmark!==''"><br />,
{{data.deliveryAddress.addressType}},
<!-- ,<br />{{data.deliveryAddress.address}} -->
<br /> {{data.deliveryAddress.building}}<span
*ngIf="data.deliveryAddress.landmark && data.deliveryAddress.landmark!==''"><br />,
{{data.deliveryAddress.landmark}}</span>
</h5>
<!-- <hr /> -->
......@@ -182,7 +184,8 @@
<ion-footer>
<div class="footer-btn">
<button class="cancel_btn" (click)="cancelOrder(data.orderId)" *ngIf="cancelDelivery > 0 && data.orderStatus != 0 && data.orderStatus != 8">
<button class="cancel_btn" (click)="cancelOrder(data.orderId)"
*ngIf="cancelDelivery > 0 && data.orderStatus != 0 && data.orderStatus != 8">
CANCEL THIS ORDER
</button>
</div>
......
......@@ -41,7 +41,7 @@ export class AddressService {
orderRef.valueChanges().subscribe(value => {
this.addressList = [];
const res = value;
this.getAddressCurrent();
// this.getAddressCurrent();
if (res.length > 0) {
res.forEach(item => {
// console.log(item);
......@@ -169,6 +169,7 @@ export class AddressService {
}
async setDefaultAddress(addId: string, userId: string) {
console.log(addId, userId);
return await new Promise(resolve => {
this.afs
.collection('address', ref => ref.where('uid', '==', userId))
......
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