Commit 6afa4f28 by Adarsh K

backup

parent 0cce2daf
...@@ -20,20 +20,25 @@ ...@@ -20,20 +20,25 @@
<ion-content> <ion-content>
<div class="nearby_map"> <div class="nearby_map">
<div class="map-inner"> <div class="map-inner">
<agm-map [latitude]="latitude" [longitude]="longitude" [zoom]="8" [backgroundColor]="'rgba(29, 27, 130,0.2)'"> <agm-map [latitude]="latitude" [longitude]="longitude" [zoom]="8"
[backgroundColor]="'rgba(29, 27, 130,0.2)'" (mapReady)="mapReady($event)"
(centerChange)="centerChange($event)">
<agm-marker [markerDraggable]="true" (dragEnd)="markerDragEnd($event)"></agm-marker> <agm-marker [markerDraggable]="true" (dragEnd)="markerDragEnd($event)"></agm-marker>
</agm-map> </agm-map>
<span class="map-pin"><img src="../../assets/pin.svg" alt=""></span> <span class="map-pin"><img src="../../assets/pin.svg" alt=""></span>
</div> </div>
<form (ngSubmit)="onSubmit(addressForm.value); addressForm.reset()" #addressForm="ngForm" method="post" class="form-horizontal"> <form (ngSubmit)="onSubmit(addressForm.value); addressForm.reset()" #addressForm="ngForm" method="post"
class="form-horizontal">
<div class="add_address_wrapper"> <div class="add_address_wrapper">
<h5>DELIVERY</h5> <h5>DELIVERY</h5>
<p>{{address}}</p> <p>{{address}}</p>
<input [(ngModel)]="addressForm.building" name="building" #building="ngModel" name="building" required placeholder="House No./ Building No" /> <input [(ngModel)]="addressForm.building" name="building" #building="ngModel" name="building" required
placeholder="House No./ Building No" />
<div class="md-errors-spacer" [hidden]="building.valid || landmark.pristine" class="ion-padding-start"> <div class="md-errors-spacer" [hidden]="building.valid || landmark.pristine" class="ion-padding-start">
Building Name is required Building Name is required
</div> </div>
<input [(ngModel)]="addressForm.landmark" name="landmark" #landmark="ngModel" name="landmark" required placeholder="Landmark" /> <input [(ngModel)]="addressForm.landmark" name="landmark" #landmark="ngModel" name="landmark" required
placeholder="Landmark" />
<div class="md-errors-spacer" [hidden]="landmark.valid || landmark.pristine" class="ion-padding-start"> <div class="md-errors-spacer" [hidden]="landmark.valid || landmark.pristine" class="ion-padding-start">
Landmark is required Landmark is required
</div> </div>
...@@ -41,24 +46,31 @@ ...@@ -41,24 +46,31 @@
<ion-row> <ion-row>
<ion-col> <ion-col>
<h6> <h6>
<input class="styled-checkbox" id="styled-check-1" type="radio" value="Home" [(ngModel)]="addressForm.addressType" name="addressType" #addressType="ngModel" required /> <input class="styled-checkbox" id="styled-check-1" type="radio" value="Home"
[(ngModel)]="addressForm.addressType" name="addressType" #addressType="ngModel"
required />
<label for="styled-check-1"><span>Home</span></label> <label for="styled-check-1"><span>Home</span></label>
</h6> </h6>
</ion-col> </ion-col>
<ion-col> <ion-col>
<h6> <h6>
<input class="styled-checkbox" id="styled-check-2" type="radio" value="Work" [(ngModel)]="addressForm.addressType" name="addressType" #addressType="ngModel" required /> <input class="styled-checkbox" id="styled-check-2" type="radio" value="Work"
[(ngModel)]="addressForm.addressType" name="addressType" #addressType="ngModel"
required />
<label for="styled-check-2"><span>Office</span></label> <label for="styled-check-2"><span>Office</span></label>
</h6> </h6>
</ion-col> </ion-col>
<ion-col> <ion-col>
<h6> <h6>
<input class="styled-checkbox" id="styled-check-3" type="radio" value="Other" [(ngModel)]="addressForm.addressType" name="addressType" #addressType="ngModel" required /> <input class="styled-checkbox" id="styled-check-3" type="radio" value="Other"
[(ngModel)]="addressForm.addressType" name="addressType" #addressType="ngModel"
required />
<label for="styled-check-3"><span>Others</span></label> <label for="styled-check-3"><span>Others</span></label>
</h6> </h6>
</ion-col> </ion-col>
</ion-row> </ion-row>
<div class="md-errors-spacer" [hidden]="addressType.valid || addressType.pristine" class="ion-padding-start"> <div class="md-errors-spacer" [hidden]="addressType.valid || addressType.pristine"
class="ion-padding-start">
Address Type is required Address Type is required
</div> </div>
</ion-grid> </ion-grid>
......
...@@ -36,6 +36,8 @@ export class ChangeaddressPage implements OnInit { ...@@ -36,6 +36,8 @@ export class ChangeaddressPage implements OnInit {
addressValid: any; addressValid: any;
lat: any; lat: any;
lng: any; lng: any;
newCenterLat: number;
newCenterLng: number;
public searchElementRef: ElementRef; public searchElementRef: ElementRef;
constructor( constructor(
...@@ -88,6 +90,19 @@ export class ChangeaddressPage implements OnInit { ...@@ -88,6 +90,19 @@ export class ChangeaddressPage implements OnInit {
} }
} }
mapReady(map) {
map.addListener('dragend', () => {
console.log(this.newCenterLat, this.newCenterLng);
this.getAddress(this.latitude, this.longitude);
});
}
centerChange(e) {
console.log(e);
this.newCenterLat = e.lat;
this.newCenterLng = e.lng;
this.getAddress(this.newCenterLat, this.newCenterLng);
}
markerDragEnd($event: MouseEvent) { markerDragEnd($event: MouseEvent) {
console.log($event); console.log($event);
this.latitude = $event.coords.lat; this.latitude = $event.coords.lat;
...@@ -126,7 +141,7 @@ export class ChangeaddressPage implements OnInit { ...@@ -126,7 +141,7 @@ export class ChangeaddressPage implements OnInit {
window.alert('No results found'); window.alert('No results found');
} }
} else { } else {
window.alert('Geocoder failed due to: ' + status); //window.alert('Geocoder failed due to: ' + status);
} }
} }
); );
...@@ -150,7 +165,7 @@ export class ChangeaddressPage implements OnInit { ...@@ -150,7 +165,7 @@ export class ChangeaddressPage implements OnInit {
setTimeout(() => { setTimeout(() => {
// tslint:disable-next-line:max-line-length // tslint:disable-next-line:max-line-length
const distanceNew = google.maps.geometry.spherical.computeDistanceBetween(new google.maps.LatLng(This.latitude, This.longitude), new google.maps.LatLng(val.pickupLocation.O, val.pickupLocation.F)); const distanceNew = google.maps.geometry.spherical.computeDistanceBetween(new google.maps.LatLng(This.newCenterLat, This.newCenterLng), new google.maps.LatLng(val.pickupLocation.O, val.pickupLocation.F));
const distanceKM = (distanceNew / 1000).toFixed(2); const distanceKM = (distanceNew / 1000).toFixed(2);
if (distanceKM < This.service.distance) { if (distanceKM < This.service.distance) {
const orderId = val.orderId; const orderId = val.orderId;
...@@ -161,7 +176,7 @@ export class ChangeaddressPage implements OnInit { ...@@ -161,7 +176,7 @@ export class ChangeaddressPage implements OnInit {
landmark: data.landmark, landmark: data.landmark,
defaultVal: 0, defaultVal: 0,
uid: This.uid, uid: This.uid,
latLng: new firebase.firestore.GeoPoint(This.latitude, This.longitude), latLng: new firebase.firestore.GeoPoint(This.newCenterLat, This.newCenterLng),
status: true status: true
}; };
console.log(postData, orderId); console.log(postData, orderId);
......
...@@ -134,7 +134,7 @@ export class CartsService { ...@@ -134,7 +134,7 @@ export class CartsService {
} }
}); });
} else { } else {
this.service.showToast('Your cart is not empty', 'top', 'my-error', 2000); this.service.showToast('You have items from another Shopping Centre', 'top', 'my-error', 2000);
resolve(false); resolve(false);
} }
}); });
......
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