Commit 8f326880 by Adarsh K

changes

parent 4ba5e826
...@@ -120,12 +120,14 @@ export class NearbyPage implements OnInit { ...@@ -120,12 +120,14 @@ export class NearbyPage implements OnInit {
mapReady(map) { mapReady(map) {
map.addListener('dragend', () => { map.addListener('dragend', () => {
console.log(this.newCenterLat, this.newCenterLng); console.log(this.newCenterLat, this.newCenterLng);
this.getAddress(this.newCenterLat, this.newCenterLng);
}); });
} }
centerChange(e) { centerChange(e) {
console.log(e); console.log(e);
this.newCenterLat = e.lat; this.newCenterLat = e.lat;
this.newCenterLng = e.lng; this.newCenterLng = e.lng;
this.getAddress(this.newCenterLat, this.newCenterLng);
} }
goToPage(path, data = null) { goToPage(path, data = null) {
......
...@@ -42,7 +42,8 @@ export class AddressService { ...@@ -42,7 +42,8 @@ export class AddressService {
defaultVal: item.defaultVal, defaultVal: item.defaultVal,
building: item.building, building: item.building,
landmark: item.landmark, landmark: item.landmark,
addressId: item.addressId addressId: item.addressId,
nearest: false
}; };
this.addressList.push(address); this.addressList.push(address);
}); });
...@@ -72,7 +73,8 @@ export class AddressService { ...@@ -72,7 +73,8 @@ export class AddressService {
defaultVal: item.defaultVal, defaultVal: item.defaultVal,
building: item.building, building: item.building,
landmark: item.landmark, landmark: item.landmark,
addressId: item.addressId addressId: item.addressId,
nearest: false
}; };
this.defaultAdd = address; this.defaultAdd = address;
console.log(this.defaultAdd); console.log(this.defaultAdd);
...@@ -203,7 +205,8 @@ export class AddressService { ...@@ -203,7 +205,8 @@ export class AddressService {
defaultVal: item.defaultVal, defaultVal: item.defaultVal,
building: item.building, building: item.building,
landmark: item.landmark, landmark: item.landmark,
addressId: item.addressId addressId: item.addressId,
nearest: true
}; };
this.nearestList.push(address); this.nearestList.push(address);
}); });
...@@ -212,6 +215,23 @@ export class AddressService { ...@@ -212,6 +215,23 @@ export class AddressService {
} else { } else {
// alert('No Orders Found'); // alert('No Orders Found');
} }
if (this.addressList.length > 0 && this.nearestList.length > 0) {
this.addressList.forEach((address) => {
const index = this.nearestList.findIndex(x => x.addressId === address.addressId);
if (index >= 0) {
address.nearest = true;
}
});
}
console.log(this.addressList);
this.addressList = this.addressList.sort((a: any, b: any) => {
return b.nearest - a.nearest;
});
console.log(this.addressList);
}); });
} else { } else {
console.log('No such document!'); console.log('No such document!');
......
...@@ -22,4 +22,5 @@ export interface AddressList { ...@@ -22,4 +22,5 @@ export interface AddressList {
building: string; building: string;
latLng: any; latLng: any;
landmark: string; landmark: string;
nearest: boolean;
} }
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