Commit 003e409a by Adarsh K

Merge branch 'adarsh' into 'master'

Adarsh See merge request !104
parents 0d8fd708 5bb12a19
...@@ -22,14 +22,16 @@ ...@@ -22,14 +22,16 @@
<ion-grid *ngFor="let address of addressService.addressList; let i = index"> <ion-grid *ngFor="let address of addressService.addressList; let i = index">
<ion-row> <ion-row>
<ion-col size="1"> <ion-col size="1">
<input type="radio" id="address_{{i}}" class="address-radio" name="address" (change)="setDefault(address.addressId)" [checked]="address.defaultVal == 1" /> <input type="radio" id="address_{{i}}" class="address-radio" name="address"
(change)="setDefault(address.addressId)" [checked]="address.defaultVal == 1" />
</ion-col> </ion-col>
<ion-col size="9"> <ion-col size="9">
<h1>{{address.addressType}}</h1> <h1>{{address.addressType}}</h1>
<h1>{{address.address}}</h1> <!-- <h1>{{address.address}}</h1> -->
<p>{{address.building}}, {{address.landmark}}</p> <p>{{address.building}}, {{address.landmark}}</p>
</ion-col> </ion-col>
<ion-col size="2" [hidden]="address.defaultVal == 1"><button class="show-btn" (click)="addressService.deleteAddress(address.addressId)"> <ion-col size="2" [hidden]="address.defaultVal == 1"><button class="show-btn"
(click)="addressService.deleteAddress(address.addressId)">
<img src="../../assets/delete.png" /></button></ion-col> <img src="../../assets/delete.png" /></button></ion-col>
</ion-row> </ion-row>
</ion-grid> </ion-grid>
......
...@@ -321,7 +321,7 @@ ...@@ -321,7 +321,7 @@
<p> <p>
{{address.building}}, <span {{address.building}}, <span
*ngIf="address.landmark && address.landmark!==''">{{address.landmark}},</span> *ngIf="address.landmark && address.landmark!==''">{{address.landmark}},</span>
{{address.address}} <!-- {{address.address}} -->
</p> </p>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
......
...@@ -31,12 +31,18 @@ ...@@ -31,12 +31,18 @@
class="form-horizontal"> 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 <!-- <input [(ngModel)]="addressForm.building" name="building" #building="ngModel" name="building" required
placeholder="House No./ Building No" /> 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.building" name="building" #building="ngModel" name="building"
placeholder="House No./ Building No" [value]="address" (keydown.enter)="$event.preventDefault()"
autocorrect="off" autocapitalize="off" spellcheck="off" type="text" #building />
<!-- <div class=" md-errors-spacer" [hidden]="building.valid || landmark.pristine" class="ion-padding-start">
Building Name is required
</div> -->
<input [(ngModel)]="addressForm.landmark" name="landmark" #landmark="ngModel" name="landmark" <input [(ngModel)]="addressForm.landmark" name="landmark" #landmark="ngModel" name="landmark"
placeholder="Landmark" /> placeholder="Landmark" />
<ion-grid> <ion-grid>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
width: 100%; width: 100%;
height: 100vh; height: 100vh;
.map-inner { .map-inner {
height: calc(100% - 348px); height: calc(100% - 375px);
position: relative; position: relative;
.map-pin { .map-pin {
position: absolute; position: absolute;
...@@ -11,8 +11,10 @@ ...@@ -11,8 +11,10 @@
-webkit-transform: translate(-50%, -50%); -webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
width: 20px; width: 20px;
height: 40px;
img { img {
margin-top: -23px; margin-top: -20px;
display: block;
} }
} }
} }
...@@ -60,6 +62,7 @@ ...@@ -60,6 +62,7 @@
margin: 0px; margin: 0px;
padding: 0px; padding: 0px;
font-weight: 800; font-weight: 800;
margin-bottom: 20px;
} }
input { input {
width: 100%; width: 100%;
...@@ -143,7 +146,7 @@ ...@@ -143,7 +146,7 @@
} }
} }
.map-inner { .map-inner {
height: calc(100% - 235px); height: calc(100% - 300px);
} }
} }
} }
\ No newline at end of file
...@@ -39,6 +39,7 @@ export class ChangeaddressPage implements OnInit { ...@@ -39,6 +39,7 @@ export class ChangeaddressPage implements OnInit {
lng: any; lng: any;
newCenterLat: number; newCenterLat: number;
newCenterLng: number; newCenterLng: number;
@ViewChild('building', { static: false })
public searchElementRef: ElementRef; public searchElementRef: ElementRef;
constructor( constructor(
...@@ -76,6 +77,20 @@ export class ChangeaddressPage implements OnInit { ...@@ -76,6 +77,20 @@ export class ChangeaddressPage implements OnInit {
this.mapsAPILoader.load().then(() => { this.mapsAPILoader.load().then(() => {
this.setCurrentLocation(); this.setCurrentLocation();
this.geoCoder = new google.maps.Geocoder(); this.geoCoder = new google.maps.Geocoder();
const autocomplete = new google.maps.places.Autocomplete(this.searchElementRef.nativeElement, {
types: ['address']
});
autocomplete.addListener('place_changed', () => {
this.ngZone.run(() => {
const place: google.maps.places.PlaceResult = autocomplete.getPlace();
if (place.geometry === undefined || place.geometry === null) {
return;
}
this.latitude = place.geometry.location.lat();
this.longitude = place.geometry.location.lng();
this.zoom = 16;
});
});
}); });
} }
// google maps zoom level // google maps zoom level
...@@ -160,6 +175,8 @@ export class ChangeaddressPage implements OnInit { ...@@ -160,6 +175,8 @@ export class ChangeaddressPage implements OnInit {
} }
onSubmit(data: any) { onSubmit(data: any) {
console.log();
const buildAddress = this.searchElementRef.nativeElement.value;
this.loader = true; this.loader = true;
this.service.get('order').then(val => { this.service.get('order').then(val => {
console.log(val); console.log(val);
...@@ -178,11 +195,12 @@ export class ChangeaddressPage implements OnInit { ...@@ -178,11 +195,12 @@ export class ChangeaddressPage implements OnInit {
); );
const distanceKM = (distanceNew / 1000).toFixed(2); const distanceKM = (distanceNew / 1000).toFixed(2);
if (distanceKM < This.service.distance) { if (distanceKM < This.service.distance) {
console.log(buildAddress);
const orderId = val.orderId; const orderId = val.orderId;
const postData: Address = { const postData: Address = {
address: This.address,
addressType: data.addressType, addressType: data.addressType,
building: data.building, address: '',
building: buildAddress,
landmark: data.landmark !== undefined ? data.landmark : '', landmark: data.landmark !== undefined ? data.landmark : '',
defaultVal: 0, defaultVal: 0,
uid: This.uid, uid: This.uid,
......
...@@ -141,6 +141,12 @@ ...@@ -141,6 +141,12 @@
</div> </div>
</ion-header> </ion-header>
<ion-content class="sort_wrappper"> <ion-content class="sort_wrappper">
<div class="location-finder">
<input type="text" placeholder="Search for location" (keydown.enter)="$event.preventDefault()"
autocorrect="off" autocapitalize="off" spellcheck="off" type="text" #building>
</div>
<agm-map [zoom]="20" [latitude]="lat" [longitude]="lng" [disableDefaultUI]="false" [zoomControl]="false" <agm-map [zoom]="20" [latitude]="lat" [longitude]="lng" [disableDefaultUI]="false" [zoomControl]="false"
[backgroundColor]="'rgba(29, 27, 130,0.2)'"> [backgroundColor]="'rgba(29, 27, 130,0.2)'">
<agm-marker [latitude]="lat" [longitude]="lng" [iconUrl]=" <agm-marker [latitude]="lat" [longitude]="lng" [iconUrl]="
...@@ -173,7 +179,7 @@ ...@@ -173,7 +179,7 @@
<p> <p>
{{address.building}}, <span {{address.building}}, <span
*ngIf="address.landmark && address.landmark!==''">{{address.landmark}},</span> *ngIf="address.landmark && address.landmark!==''">{{address.landmark}},</span>
{{address.address}} <!-- {{address.address}} -->
</p> </p>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
......
...@@ -255,6 +255,43 @@ ...@@ -255,6 +255,43 @@
right: 0px; right: 0px;
bottom: 0px; bottom: 0px;
z-index: 99; z-index: 99;
.location-finder {
position: absolute;
top: 15px;
left: 0;
right: 0;
padding: 0 20px;
z-index: 1;
input {
width: 100%;
border: 1px solid #e0e0e0;
outline: none;
padding: 8px 15px 8px 35px;
border-radius: 25px;
background-image: url('/assets/search_2.png');
background-position: 15px;
background-repeat: no-repeat;
background-size: 15px;
}
}
agm-map { agm-map {
width: 100%; width: 100%;
height: 100vh; height: 100vh;
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit, ViewChild, ElementRef, NgZone } from '@angular/core';
import { Location } from '@angular/common'; import { Location } from '@angular/common';
import { trigger, transition, animate, style } from '@angular/animations'; import { trigger, transition, animate, style } from '@angular/animations';
import { MapsAPILoader, MouseEvent } from '@agm/core'; import { MapsAPILoader, MouseEvent } from '@agm/core';
...@@ -35,7 +35,7 @@ import { AuthService } from 'src/config/auth.service'; ...@@ -35,7 +35,7 @@ import { AuthService } from 'src/config/auth.service';
] ]
}) })
export class HomePage implements OnInit { export class HomePage implements OnInit {
isShow = false; isShow = true;
searchShow = false; searchShow = false;
public lat = 51.678418; public lat = 51.678418;
public lng = 7.809007; public lng = 7.809007;
...@@ -47,6 +47,8 @@ export class HomePage implements OnInit { ...@@ -47,6 +47,8 @@ export class HomePage implements OnInit {
slideOpts = { slideOpts = {
slidesPerView: 1.5 slidesPerView: 1.5
}; };
@ViewChild('building', { static: false })
public searchElementRef: ElementRef;
constructor( constructor(
private router: Router, private router: Router,
...@@ -63,11 +65,12 @@ export class HomePage implements OnInit { ...@@ -63,11 +65,12 @@ export class HomePage implements OnInit {
private searchService: SearchService, private searchService: SearchService,
private productsService: ProductsService, private productsService: ProductsService,
private subjectService: SubjectService, private subjectService: SubjectService,
private authService: AuthService private authService: AuthService,
private ngZone: NgZone,
) { ) {
this.loader = false; this.loader = false;
this.address = 'Pick your Location'; this.address = 'Pick your Location';
this.isShow = false;
const users = this.service.get('user').then(data => { const users = this.service.get('user').then(data => {
if (data) { if (data) {
data = JSON.parse(data); data = JSON.parse(data);
...@@ -97,6 +100,35 @@ export class HomePage implements OnInit { ...@@ -97,6 +100,35 @@ export class HomePage implements OnInit {
this.menuCtrl.enable(true); this.menuCtrl.enable(true);
} }
resetMap() {
console.log('called');
const This = this;
setTimeout(() => {
This.mapsAPILoader.load().then(() => {
This.setCurrentLocation();
This.geoCoder = new google.maps.Geocoder();
const autocomplete = new google.maps.places.Autocomplete(This.searchElementRef.nativeElement, {
types: ['address']
});
autocomplete.addListener('place_changed', () => {
This.ngZone.run(() => {
const place: google.maps.places.PlaceResult = autocomplete.getPlace();
if (place.geometry === undefined || place.geometry === null) {
return;
}
This.lat = place.geometry.location.lat();
This.lng = place.geometry.location.lng();
This.getAddress(This.lat, This.lng);
console.log(This.lat, This.lng, This.service.distance);
This.centerService.getNearBy(This.lat, This.lng, This.service.distance);
This.istoggle();
});
});
});
}, 1000);
}
private setCurrentLocation() { private setCurrentLocation() {
const This = this; const This = this;
if ('geolocation' in navigator) { if ('geolocation' in navigator) {
...@@ -137,6 +169,8 @@ export class HomePage implements OnInit { ...@@ -137,6 +169,8 @@ export class HomePage implements OnInit {
.setDefaultAddress(address.addressId, this.custId) .setDefaultAddress(address.addressId, this.custId)
.then(() => { .then(() => {
this.address = address.address; this.address = address.address;
this.lat = address.latLng.latitude;
this.lng = address.latLng.longitude;
console.log(address.latLng); console.log(address.latLng);
this.centerService.getNearBy( this.centerService.getNearBy(
address.latLng.latitude, address.latLng.latitude,
...@@ -190,6 +224,9 @@ export class HomePage implements OnInit { ...@@ -190,6 +224,9 @@ export class HomePage implements OnInit {
istoggle() { istoggle() {
this.isShow = !this.isShow; this.isShow = !this.isShow;
if (this.isShow) {
this.resetMap();
}
console.log(this.isShow, 'Is SHow'); console.log(this.isShow, 'Is SHow');
this.subjectService.setTabData(!this.isShow); this.subjectService.setTabData(!this.isShow);
} }
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<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" <agm-map [latitude]="latitude" [longitude]="longitude" [zoom]="zoom"
[backgroundColor]="'rgba(29, 27, 130,0.2)'" (mapReady)="mapReady($event)" [backgroundColor]="'rgba(29, 27, 130,0.2)'" (mapReady)="mapReady($event)"
(centerChange)="centerChange($event)"> (centerChange)="centerChange($event)">
<agm-marker [markerDraggable]="true" (dragEnd)="markerDragEnd($event)" [iconUrl]=" <agm-marker [markerDraggable]="true" (dragEnd)="markerDragEnd($event)" [iconUrl]="
...@@ -37,12 +37,12 @@ ...@@ -37,12 +37,12 @@
class="form-horizontal"> class="form-horizontal">
<div class="add_address_wrapper"> <div class="add_address_wrapper">
<h5>DELIVERY</h5> <h5>DELIVERY</h5>
<p>{{address}}</p> <input [(ngModel)]="addressForm.building" name="building" #building="ngModel" name="building"
<input [(ngModel)]="addressForm.building" name="building" #building="ngModel" name="building" required placeholder="House No./ Building No" [value]="address" (keydown.enter)="$event.preventDefault()"
placeholder="House No./ Building No" /> autocorrect="off" autocapitalize="off" spellcheck="off" type="text" #building />
<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" <input [(ngModel)]="addressForm.landmark" name="landmark" #landmark="ngModel" name="landmark"
placeholder="Landmark" /> placeholder="Landmark" />
<ion-grid> <ion-grid>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
.map-inner { .map-inner {
height: calc(100% - 348px); height: calc(100% - 324px);
position: relative; position: relative;
.map-pin { .map-pin {
position: absolute; position: absolute;
...@@ -15,8 +15,10 @@ ...@@ -15,8 +15,10 @@
-webkit-transform: translate(-50%, -50%); -webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
width: 20px; width: 20px;
height: 40px;
img { img {
margin-top: -23px; margin-top: -20px;
display: block;
} }
} }
} }
...@@ -74,6 +76,7 @@ ...@@ -74,6 +76,7 @@
margin: 0px; margin: 0px;
padding: 0px; padding: 0px;
font-weight: 800; font-weight: 800;
margin-bottom: 20px;
} }
input { input {
width: 100%; width: 100%;
...@@ -166,7 +169,7 @@ ...@@ -166,7 +169,7 @@
} }
} }
.map-inner { .map-inner {
height: calc(100% - 235px); height: calc(100% - 250px);
} }
} }
} }
\ No newline at end of file
...@@ -33,6 +33,7 @@ export class NearbyPage implements OnInit { ...@@ -33,6 +33,7 @@ export class NearbyPage implements OnInit {
uid: string; uid: string;
type: any; type: any;
loader: boolean; loader: boolean;
@ViewChild('building', { static: false })
public searchElementRef: ElementRef; public searchElementRef: ElementRef;
newCenterLat: number; newCenterLat: number;
...@@ -67,6 +68,20 @@ export class NearbyPage implements OnInit { ...@@ -67,6 +68,20 @@ export class NearbyPage implements OnInit {
this.mapsAPILoader.load().then(() => { this.mapsAPILoader.load().then(() => {
this.setCurrentLocation(); this.setCurrentLocation();
this.geoCoder = new google.maps.Geocoder(); this.geoCoder = new google.maps.Geocoder();
const autocomplete = new google.maps.places.Autocomplete(this.searchElementRef.nativeElement, {
types: ['address']
});
autocomplete.addListener('place_changed', () => {
this.ngZone.run(() => {
const place: google.maps.places.PlaceResult = autocomplete.getPlace();
if (place.geometry === undefined || place.geometry === null) {
return;
}
this.latitude = place.geometry.location.lat();
this.longitude = place.geometry.location.lng();
this.zoom = 16;
});
});
}); });
} }
// google maps zoom level // google maps zoom level
...@@ -75,14 +90,14 @@ export class NearbyPage implements OnInit { ...@@ -75,14 +90,14 @@ export class NearbyPage implements OnInit {
console.log('map-called'); console.log('map-called');
if ('geolocation' in navigator) { if ('geolocation' in navigator) {
console.log(navigator); console.log(navigator);
this.latitude = -33.87276; /* this.latitude = -33.87276;
this.longitude = 151.20534; this.longitude = 151.20534; */
this.zoom = 8; this.zoom = 24;
this.getAddress(this.latitude, this.longitude); this.getAddress(this.latitude, this.longitude);
navigator.geolocation.getCurrentPosition(position => { navigator.geolocation.getCurrentPosition(position => {
this.latitude = position.coords.latitude; this.latitude = position.coords.latitude;
this.longitude = position.coords.longitude; this.longitude = position.coords.longitude;
this.zoom = 8; this.zoom = 24;
this.getAddress(this.latitude, this.longitude); this.getAddress(this.latitude, this.longitude);
}); });
} }
...@@ -104,7 +119,7 @@ export class NearbyPage implements OnInit { ...@@ -104,7 +119,7 @@ export class NearbyPage implements OnInit {
console.log(status); console.log(status);
if (status === 'OK') { if (status === 'OK') {
if (results[0]) { if (results[0]) {
this.zoom = 12; this.zoom = 24;
this.address = results[0].formatted_address; this.address = results[0].formatted_address;
console.log(this.address); console.log(this.address);
} else { } else {
...@@ -144,8 +159,8 @@ export class NearbyPage implements OnInit { ...@@ -144,8 +159,8 @@ export class NearbyPage implements OnInit {
console.log(data); console.log(data);
const postData: Address = { const postData: Address = {
address: this.address, address: this.address,
addressType: data.addressType, addressType: '',
building: data.building, building: this.searchElementRef.nativeElement.value,
landmark: data.landmark !== undefined ? data.landmark : '', landmark: data.landmark !== undefined ? data.landmark : '',
defaultVal: 0, defaultVal: 0,
uid: this.uid, uid: this.uid,
......
...@@ -115,7 +115,8 @@ ...@@ -115,7 +115,8 @@
</div> </div>
<h5 *ngIf="data.deliveryAddress"> <h5 *ngIf="data.deliveryAddress">
{{data.deliveryAddress.addressType}},<br />{{data.deliveryAddress.address}}, {{data.deliveryAddress.addressType}}
<!-- ,<br />{{data.deliveryAddress.address}} -->,
<br /> {{data.deliveryAddress.building}}<span <br /> {{data.deliveryAddress.building}}<span
*ngIf="data.deliveryAddress.landmark && data.deliveryAddress.landmark!==''"><br />, *ngIf="data.deliveryAddress.landmark && data.deliveryAddress.landmark!==''"><br />,
{{data.deliveryAddress.landmark}}</span> {{data.deliveryAddress.landmark}}</span>
......
...@@ -56,7 +56,7 @@ export class CenterService { ...@@ -56,7 +56,7 @@ export class CenterService {
} }
public async getNearBy(latitude, longitude, distance) { public async getNearBy(latitude, longitude, distance) {
console.log(distance); console.log(latitude, longitude, distance);
const This = this; const This = this;
const state = true; const state = true;
...@@ -103,7 +103,7 @@ export class CenterService { ...@@ -103,7 +103,7 @@ export class CenterService {
}; };
this.nearcenters.push(center); this.nearcenters.push(center);
}); });
// console.log(this.nearcenters); console.log(this.nearcenters);
} else { } else {
// alert('No Orders Found'); // alert('No Orders Found');
} }
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<body> <body>
<script <script
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBnCzDk6ec1OJFcW5FYgxP3LWVHMNumGDM&libraries=geometry"></script> src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBnCzDk6ec1OJFcW5FYgxP3LWVHMNumGDM&libraries=geometry,places"></script>
<app-root></app-root> <app-root></app-root>
</body> </body>
......
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