@aggdirect/coolmap-services 1.1.6 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,762 +10,763 @@ import * as i1 from '@angular/common/http';
10
10
  import * as i2 from '@angular/material/snack-bar';
11
11
  import * as i2$1 from '@angular/platform-browser';
12
12
 
13
- class Route {
14
- constructor() {
15
- this.index = 0;
16
- }
17
- }
18
- const EstinationData = ['estimated_distance', 'estimated_time'];
19
- var EstinationEnum;
20
- (function (EstinationEnum) {
21
- EstinationEnum["estimated_distance"] = "miles";
22
- EstinationEnum["estimated_time"] = "time";
23
- })(EstinationEnum || (EstinationEnum = {}));
24
- const JobCodeOverviewData = ['order_number', 'customer_name', 'project', 'unit', 'material', 'customer_contact', 'delivery_contact', 'pickup_location', 'delivery_location'];
25
- var JobCodeOverviewEnum;
26
- (function (JobCodeOverviewEnum) {
27
- JobCodeOverviewEnum["material"] = "Material";
28
- JobCodeOverviewEnum["order_number"] = "Job Code";
29
- JobCodeOverviewEnum["customer_name"] = "Customer";
30
- JobCodeOverviewEnum["customer_contact"] = "Customer Contact";
31
- JobCodeOverviewEnum["delivery_contact"] = "Delivery Contact";
32
- JobCodeOverviewEnum["project"] = "Project Name";
33
- JobCodeOverviewEnum["unit"] = "Job Type";
34
- JobCodeOverviewEnum["pickup_location"] = "Pickup";
35
- JobCodeOverviewEnum["delivery_location"] = "Delivery";
36
- })(JobCodeOverviewEnum || (JobCodeOverviewEnum = {}));
37
- const DriversmsCardKey = ['order_number', 'date', 'values', 'material', 'unit', 'pickup_location', 'delivery_location'];
38
- var DriverSmsCardEnum;
39
- (function (DriverSmsCardEnum) {
40
- DriverSmsCardEnum["order_number"] = "Jobcode";
41
- DriverSmsCardEnum["date"] = "Date";
42
- DriverSmsCardEnum["values"] = "Total tasks";
43
- DriverSmsCardEnum["material"] = "Material";
44
- DriverSmsCardEnum["unit"] = "Unit";
45
- DriverSmsCardEnum["pickup_location"] = "Pickup Address";
46
- DriverSmsCardEnum["delivery_location"] = "Delivery Address";
47
- })(DriverSmsCardEnum || (DriverSmsCardEnum = {}));
48
- class PopupData {
49
- }
50
- class CoolmapConfigModel {
13
+ class Route {
14
+ constructor() {
15
+ this.index = 0;
16
+ }
17
+ }
18
+ const EstinationData = ['estimated_distance', 'estimated_time'];
19
+ var EstinationEnum;
20
+ (function (EstinationEnum) {
21
+ EstinationEnum["estimated_distance"] = "miles";
22
+ EstinationEnum["estimated_time"] = "time";
23
+ })(EstinationEnum || (EstinationEnum = {}));
24
+ const JobCodeOverviewData = ['order_number', 'customer_name', 'project', 'unit', 'material', 'customer_contact', 'delivery_contact', 'pickup_location', 'delivery_location'];
25
+ var JobCodeOverviewEnum;
26
+ (function (JobCodeOverviewEnum) {
27
+ JobCodeOverviewEnum["material"] = "Material";
28
+ JobCodeOverviewEnum["order_number"] = "Job Code";
29
+ JobCodeOverviewEnum["customer_name"] = "Customer";
30
+ JobCodeOverviewEnum["customer_contact"] = "Customer Contact";
31
+ JobCodeOverviewEnum["delivery_contact"] = "Delivery Contact";
32
+ JobCodeOverviewEnum["project"] = "Project Name";
33
+ JobCodeOverviewEnum["unit"] = "Job Type";
34
+ JobCodeOverviewEnum["pickup_location"] = "Pickup";
35
+ JobCodeOverviewEnum["delivery_location"] = "Delivery";
36
+ })(JobCodeOverviewEnum || (JobCodeOverviewEnum = {}));
37
+ const DriversmsCardKey = ['order_number', 'date', 'values', 'material', 'unit', 'pickup_location', 'delivery_location'];
38
+ var DriverSmsCardEnum;
39
+ (function (DriverSmsCardEnum) {
40
+ DriverSmsCardEnum["order_number"] = "Jobcode";
41
+ DriverSmsCardEnum["date"] = "Date";
42
+ DriverSmsCardEnum["values"] = "Total tasks";
43
+ DriverSmsCardEnum["material"] = "Material";
44
+ DriverSmsCardEnum["unit"] = "Unit";
45
+ DriverSmsCardEnum["pickup_location"] = "Pickup Address";
46
+ DriverSmsCardEnum["delivery_location"] = "Delivery Address";
47
+ })(DriverSmsCardEnum || (DriverSmsCardEnum = {}));
48
+ class PopupData {
49
+ }
50
+ class CoolmapConfigModel {
51
51
  }
52
52
 
53
- class UtilsService {
54
- constructor(http, snackBar, config) {
55
- this.http = http;
56
- this.snackBar = snackBar;
57
- this.config = config;
58
- this.analyticsRESTURL = '';
59
- this.RESTURLPrefix = '';
60
- this.pickupOptions = [];
61
- this.destOptions = [];
62
- this.ownerOptions = [];
63
- this.customerOptions = [];
64
- this.unitOptions = [];
65
- this.materialOptions = [];
66
- this.jcodeOptions = [];
67
- this.driverOption = [];
68
- this.truckingCompanayOption = [];
69
- this.routeNameOptions = [];
70
- this.preventnavChange = new BehaviorSubject(false);
71
- this.navChangeObserve = this.preventnavChange.asObservable();
72
- this.clearViewRouteforJobCode = new BehaviorSubject(false);
73
- this.clearViewRouteforJobCodeObserve = this.clearViewRouteforJobCode.asObservable();
74
- this.preVentJobdetailclose = new BehaviorSubject(false);
75
- this.getpreVentJobdetailclose = this.preVentJobdetailclose.asObservable();
76
- this.routeDetailsUtility = new BehaviorSubject({});
77
- this.getrouteDetailsUtility = this.routeDetailsUtility.asObservable();
78
- this.removeMapEntity = new BehaviorSubject({});
79
- this.removeMapEntityUtility = this.removeMapEntity.asObservable();
80
- this.dict = new Map();
81
- this.analyticsRESTURL = config.analyticsRESTURL;
82
- this.RESTURLPrefix = config.RESTURLPrefix;
83
- }
84
- getDateFormat(strVal, seprater) {
85
- seprater = seprater ? seprater : '-';
86
- const mydate = strVal;
87
- return (mydate === null || mydate === void 0 ? void 0 : mydate.getFullYear()) + seprater + ((mydate ? mydate.getMonth() : 0) + 1) + seprater + (mydate === null || mydate === void 0 ? void 0 : mydate.getDate());
88
- }
89
- getData(path) { return this.http.get(`${this.analyticsRESTURL}${this.config.repository}/${path}`); }
90
- postdata(path, data) { return this.http.post(`${this.analyticsRESTURL}${this.config.repository}/${path}`, data); }
91
- postDataWithRestUrl(path, data) { return this.http.post(`${this.RESTURLPrefix}${path}`, data); }
92
- fetchAutoCompleteLocations(keyword) {
93
- return this.http.get(`https://api.mapbox.com/geocoding/v5/mapbox.places/${keyword}.json?access_token=${this.config.mapboxAccessToken}&country=US`);
94
- }
95
- openSnackBar(message, className) {
96
- this.snackBar.open(message, '', {
97
- duration: 5000, verticalPosition: 'top', horizontalPosition: 'center', panelClass: [className ? className : 'default']
98
- });
99
- }
100
- makeOptions(item) {
101
- var _a;
102
- if (item.order_number) {
103
- (this.jcodeOptions.findIndex((elem) => elem.job_id === item.job_id) === -1) ? this.jcodeOptions.push({ job_code: item.order_number, job_id: item.job_id }) : null;
104
- if (item.driver_list && ((_a = item.driver_list) === null || _a === void 0 ? void 0 : _a.length) > 0) {
105
- item.driver_list.forEach((driver) => {
106
- this.driverOption.findIndex(elem => elem === driver['driver_name']) === -1 ? this.driverOption.push(driver['driver_name']) : null;
107
- this.truckingCompanayOption.findIndex(elem => elem === driver['trucking_company']) === -1 ? this.truckingCompanayOption.push(driver['trucking_company']) : null;
108
- });
109
- }
110
- }
111
- ((this.pickupOptions.findIndex((elem) => elem === item.pickup_location)) === -1) ? this.pickupOptions.push(item.pickup_location) : null;
112
- ((this.destOptions.findIndex((elem) => elem === item.delivery_location)) === -1) ? this.destOptions.push(item.delivery_location) : null;
113
- (this.customerOptions.findIndex((customer) => customer === item.customer_name) === -1) ? this.customerOptions.push(item.customer_name) : null;
114
- (this.unitOptions.findIndex((elem) => elem === item.unit) === -1) ? this.unitOptions.push(item.unit) : null;
115
- (this.materialOptions.findIndex((elem) => elem === item.material) === -1) ? this.materialOptions.push(item.material) : null;
116
- if (item.route_name)
117
- this.routeNameOptions.findIndex(elem => elem === item.route_name) === -1 ? this.routeNameOptions.push(item.route_name) : null;
118
- }
119
- filter(value, filters) {
120
- if (typeof value !== 'string') {
121
- return [];
122
- }
123
- const filterValue = value.toLowerCase();
124
- if (filterValue === '') {
125
- return [];
126
- }
127
- const searchResults = [];
128
- this.unitOptions.map(unit => {
129
- if (unit.toLowerCase().includes(filterValue)) {
130
- searchResults.push({ "type": "unit", "label": unit, "value": unit });
131
- }
132
- });
133
- this.customerOptions.map(unit => {
134
- if (unit.toLowerCase().includes(filterValue)) {
135
- searchResults.push({ "type": "customer", "label": unit, "value": unit });
136
- }
137
- });
138
- this.materialOptions.map(unit => {
139
- if (unit.toLowerCase().includes(filterValue)) {
140
- searchResults.push({ "type": "material", "label": unit, "value": unit });
141
- }
142
- });
143
- this.pickupOptions.map(unit => {
144
- if (unit.toLowerCase().includes(filterValue)) {
145
- searchResults.push({ "type": "pickup location", "label": unit, "value": unit });
146
- }
147
- });
148
- this.destOptions.map(unit => {
149
- if (unit.toLowerCase().includes(filterValue)) {
150
- searchResults.push({ "type": "destination location", "label": unit, "value": unit });
151
- }
152
- });
153
- this.jcodeOptions.map(unit => {
154
- if (unit.job_code.toLowerCase().includes(filterValue)) {
155
- searchResults.push({ "type": "job", "label": unit['job_code'], "value": unit });
156
- }
157
- });
158
- this.driverOption.map(unit => {
159
- if (unit.toLowerCase().includes(filterValue)) {
160
- searchResults.push({ "type": "Driver", "label": unit, "value": unit });
161
- }
162
- });
163
- this.truckingCompanayOption.map(unit => {
164
- if (unit.toLowerCase().includes(filterValue)) {
165
- searchResults.push({ "type": "Trucking Company", "label": unit, "value": unit });
166
- }
167
- });
168
- this.routeNameOptions.map(unit => {
169
- if (unit.toLowerCase().includes(filterValue)) {
170
- searchResults.push({ "type": "Route name", "label": unit, "value": unit });
171
- }
172
- });
173
- const searchDict = {};
174
- filters.map((filter) => {
175
- searchDict[filter['name'] + filter['type']] = filter;
176
- });
177
- const furtherFilter = [];
178
- searchResults.map(search => {
179
- if ((search['label'] + search['type']) in searchDict) { }
180
- else {
181
- furtherFilter.push(search);
182
- }
183
- });
184
- return furtherFilter;
185
- }
186
- getSearchResults(list, filterval) {
187
- return list.filter(element => {
188
- var _a, _b;
189
- const result_list_boolean = [];
190
- if (filterval.length > 0) {
191
- if (filterval[0]['type'] === 'unit') {
192
- result_list_boolean.push(filterval[0]['name'] === element[filterval[0]['type']]);
193
- }
194
- if (filterval[0]['type'] === 'customer') {
195
- result_list_boolean.push(filterval[0]['name'] === element['customer_name']);
196
- }
197
- if (filterval[0]['type'] === 'material') {
198
- result_list_boolean.push(filterval[0]['name'] === element[filterval[0]['type']]);
199
- }
200
- if (filterval[0]['type'] === 'pickup location') {
201
- result_list_boolean.push(filterval[0]['name'] === element['pickup_location']);
202
- }
203
- if (filterval[0]['type'] === 'destination location') {
204
- result_list_boolean.push(filterval[0]['name'] === element['delivery_location']);
205
- }
206
- if (filterval[0]['type'] === 'job') {
207
- result_list_boolean.push(filterval[0]['name'] === element['order_number']);
208
- }
209
- if (filterval[0]['type'] === 'Route name') {
210
- result_list_boolean.push(filterval[0]['name'] === element['route_name']);
211
- }
212
- if (filterval[0]['type'] === 'Driver') {
213
- const index = (_a = element.driver_list) === null || _a === void 0 ? void 0 : _a.findIndex(ele => { return filterval[0]['name'] === ele['driver_name']; });
214
- if (index !== -1)
215
- result_list_boolean.push(true);
216
- }
217
- if (filterval[0]['type'] === 'Trucking Company') {
218
- const index = (_b = element.driver_list) === null || _b === void 0 ? void 0 : _b.findIndex(ele => { return filterval[0]['name'] === ele['trucking_company']; });
219
- if (index !== -1)
220
- result_list_boolean.push(true);
221
- }
222
- }
223
- if (result_list_boolean.length > 0) {
224
- return result_list_boolean.reduce((prev, curr) => prev && curr);
225
- }
226
- return false;
227
- });
228
- }
229
- clearOptions() {
230
- this.pickupOptions = [];
231
- this.destOptions = [];
232
- this.ownerOptions = [];
233
- this.customerOptions = [];
234
- this.unitOptions = [];
235
- this.materialOptions = [];
236
- this.jcodeOptions = [];
237
- this.routeNameOptions = [];
238
- }
239
- setdictValue(key, value) {
240
- this.dict.set(key, value);
241
- }
242
- getdictValue(key) {
243
- return JSON.parse(this.dict.get(key));
244
- }
245
- removedictValue(key) {
246
- this.dict.delete(key);
247
- }
248
- conveySearchIcon(value) {
249
- if (value && typeof (value) !== 'object')
250
- return true;
251
- return false;
252
- }
253
- fetchUnitsList() {
254
- return new Promise((resolve, reject) => {
255
- if (!this.unitsList) {
256
- this.getData('unit/list/view').subscribe((res) => {
257
- if (res) {
258
- this.unitsList = res.data;
259
- resolve(this.unitsList);
260
- }
261
- });
262
- }
263
- else {
264
- resolve(this.unitsList);
265
- }
266
- });
267
- }
268
- fetchMaterialsList() {
269
- return new Promise((resolve, reject) => {
270
- if (!this.materialsList) {
271
- this.getData('material/list/view').subscribe(((res) => {
272
- res.data.sort((a, b) => a.material.localeCompare(b.material));
273
- this.materialsList = res.data;
274
- resolve(this.materialsList);
275
- }));
276
- }
277
- else {
278
- resolve(this.materialsList);
279
- }
280
- });
281
- }
282
- fetchCustomersList() {
283
- return new Promise((resolve, reject) => {
284
- if (!this.customersList) {
285
- this.getData('company/list/view').subscribe((res) => {
286
- if (res) {
287
- this.customersList = res.data;
288
- resolve(this.customersList);
289
- }
290
- });
291
- }
292
- else {
293
- resolve(this.customersList);
294
- }
295
- });
296
- }
297
- }
298
- UtilsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UtilsService, deps: [{ token: i1.HttpClient }, { token: i2.MatSnackBar }, { token: 'memberData' }], target: i0.ɵɵFactoryTarget.Injectable });
299
- UtilsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UtilsService, providedIn: 'root' });
300
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UtilsService, decorators: [{
301
- type: Injectable,
302
- args: [{ providedIn: 'root' }]
303
- }], ctorParameters: function () {
304
- return [{ type: i1.HttpClient }, { type: i2.MatSnackBar }, { type: CoolmapConfigModel, decorators: [{
305
- type: Inject,
306
- args: ['memberData']
307
- }] }];
53
+ class UtilsService {
54
+ constructor(http, snackBar, config) {
55
+ this.http = http;
56
+ this.snackBar = snackBar;
57
+ this.config = config;
58
+ this.analyticsRESTURL = '';
59
+ this.RESTURLPrefix = '';
60
+ this.pickupOptions = [];
61
+ this.destOptions = [];
62
+ this.ownerOptions = [];
63
+ this.customerOptions = [];
64
+ this.unitOptions = [];
65
+ this.materialOptions = [];
66
+ this.jcodeOptions = [];
67
+ this.driverOption = [];
68
+ this.truckingCompanayOption = [];
69
+ this.routeNameOptions = [];
70
+ this.preventnavChange = new BehaviorSubject(false);
71
+ this.navChangeObserve = this.preventnavChange.asObservable();
72
+ this.clearViewRouteforJobCode = new BehaviorSubject(false);
73
+ this.clearViewRouteforJobCodeObserve = this.clearViewRouteforJobCode.asObservable();
74
+ this.preVentJobdetailclose = new BehaviorSubject(false);
75
+ this.getpreVentJobdetailclose = this.preVentJobdetailclose.asObservable();
76
+ this.routeDetailsUtility = new BehaviorSubject({});
77
+ this.getrouteDetailsUtility = this.routeDetailsUtility.asObservable();
78
+ this.removeMapEntity = new BehaviorSubject({});
79
+ this.removeMapEntityUtility = this.removeMapEntity.asObservable();
80
+ this.dict = new Map();
81
+ this.analyticsRESTURL = config.analyticsRESTURL;
82
+ this.RESTURLPrefix = config.RESTURLPrefix;
83
+ }
84
+ getDateFormat(strVal, seprater) {
85
+ seprater = seprater ? seprater : '-';
86
+ const mydate = strVal;
87
+ return (mydate === null || mydate === void 0 ? void 0 : mydate.getFullYear()) + seprater + ((mydate ? mydate.getMonth() : 0) + 1) + seprater + (mydate === null || mydate === void 0 ? void 0 : mydate.getDate());
88
+ }
89
+ getData(path) { return this.http.get(`${this.analyticsRESTURL}${this.config.repository}/${path}`); }
90
+ postdata(path, data) { return this.http.post(`${this.analyticsRESTURL}${this.config.repository}/${path}`, data); }
91
+ postDataWithRestUrl(path, data) { return this.http.post(`${this.RESTURLPrefix}${path}`, data); }
92
+ fetchAutoCompleteLocations(keyword) {
93
+ return this.http.get(`https://api.mapbox.com/geocoding/v5/mapbox.places/${keyword}.json?access_token=${this.config.mapboxAccessToken}&country=US`);
94
+ }
95
+ openSnackBar(message, className) {
96
+ this.snackBar.open(message, '', {
97
+ duration: 5000, verticalPosition: 'top', horizontalPosition: 'center', panelClass: [className ? className : 'default']
98
+ });
99
+ }
100
+ makeOptions(item) {
101
+ var _a;
102
+ if (item.order_number) {
103
+ (this.jcodeOptions.findIndex((elem) => elem.job_id === item.job_id) === -1) ? this.jcodeOptions.push({ job_code: item.order_number, job_id: item.job_id }) : null;
104
+ if (item.driver_list && ((_a = item.driver_list) === null || _a === void 0 ? void 0 : _a.length) > 0) {
105
+ item.driver_list.forEach((driver) => {
106
+ this.driverOption.findIndex(elem => elem === driver['driver_name']) === -1 ? this.driverOption.push(driver['driver_name']) : null;
107
+ this.truckingCompanayOption.findIndex(elem => elem === driver['trucking_company']) === -1 ? this.truckingCompanayOption.push(driver['trucking_company']) : null;
108
+ });
109
+ }
110
+ }
111
+ ((this.pickupOptions.findIndex((elem) => elem === item.pickup_location)) === -1) ? this.pickupOptions.push(item.pickup_location) : null;
112
+ ((this.destOptions.findIndex((elem) => elem === item.delivery_location)) === -1) ? this.destOptions.push(item.delivery_location) : null;
113
+ (this.customerOptions.findIndex((customer) => customer === item.customer_name) === -1) ? this.customerOptions.push(item.customer_name) : null;
114
+ (this.unitOptions.findIndex((elem) => elem === item.unit) === -1) ? this.unitOptions.push(item.unit) : null;
115
+ (this.materialOptions.findIndex((elem) => elem === item.material) === -1) ? this.materialOptions.push(item.material) : null;
116
+ if (item.route_name)
117
+ this.routeNameOptions.findIndex(elem => elem === item.route_name) === -1 ? this.routeNameOptions.push(item.route_name) : null;
118
+ }
119
+ filter(value, filters) {
120
+ if (typeof value !== 'string') {
121
+ return [];
122
+ }
123
+ const filterValue = value.toLowerCase();
124
+ if (filterValue === '') {
125
+ return [];
126
+ }
127
+ const searchResults = [];
128
+ this.unitOptions.map(unit => {
129
+ if (unit.toLowerCase().includes(filterValue)) {
130
+ searchResults.push({ "type": "unit", "label": unit, "value": unit });
131
+ }
132
+ });
133
+ this.customerOptions.map(unit => {
134
+ if (unit.toLowerCase().includes(filterValue)) {
135
+ searchResults.push({ "type": "customer", "label": unit, "value": unit });
136
+ }
137
+ });
138
+ this.materialOptions.map(unit => {
139
+ if (unit.toLowerCase().includes(filterValue)) {
140
+ searchResults.push({ "type": "material", "label": unit, "value": unit });
141
+ }
142
+ });
143
+ this.pickupOptions.map(unit => {
144
+ if (unit.toLowerCase().includes(filterValue)) {
145
+ searchResults.push({ "type": "pickup location", "label": unit, "value": unit });
146
+ }
147
+ });
148
+ this.destOptions.map(unit => {
149
+ if (unit.toLowerCase().includes(filterValue)) {
150
+ searchResults.push({ "type": "destination location", "label": unit, "value": unit });
151
+ }
152
+ });
153
+ this.jcodeOptions.map(unit => {
154
+ if (unit.job_code.toLowerCase().includes(filterValue)) {
155
+ searchResults.push({ "type": "job", "label": unit['job_code'], "value": unit });
156
+ }
157
+ });
158
+ this.driverOption.map(unit => {
159
+ if (unit.toLowerCase().includes(filterValue)) {
160
+ searchResults.push({ "type": "Driver", "label": unit, "value": unit });
161
+ }
162
+ });
163
+ this.truckingCompanayOption.map(unit => {
164
+ if (unit.toLowerCase().includes(filterValue)) {
165
+ searchResults.push({ "type": "Trucking Company", "label": unit, "value": unit });
166
+ }
167
+ });
168
+ this.routeNameOptions.map(unit => {
169
+ if (unit.toLowerCase().includes(filterValue)) {
170
+ searchResults.push({ "type": "Route name", "label": unit, "value": unit });
171
+ }
172
+ });
173
+ const searchDict = {};
174
+ filters.map((filter) => {
175
+ searchDict[filter['name'] + filter['type']] = filter;
176
+ });
177
+ const furtherFilter = [];
178
+ searchResults.map(search => {
179
+ if ((search['label'] + search['type']) in searchDict) { }
180
+ else {
181
+ furtherFilter.push(search);
182
+ }
183
+ });
184
+ return furtherFilter;
185
+ }
186
+ getSearchResults(list, filterval) {
187
+ return list.filter(element => {
188
+ var _a, _b;
189
+ const result_list_boolean = [];
190
+ if (filterval.length > 0) {
191
+ if (filterval[0]['type'] === 'unit') {
192
+ result_list_boolean.push(filterval[0]['name'] === element[filterval[0]['type']]);
193
+ }
194
+ if (filterval[0]['type'] === 'customer') {
195
+ result_list_boolean.push(filterval[0]['name'] === element['customer_name']);
196
+ }
197
+ if (filterval[0]['type'] === 'material') {
198
+ result_list_boolean.push(filterval[0]['name'] === element[filterval[0]['type']]);
199
+ }
200
+ if (filterval[0]['type'] === 'pickup location') {
201
+ result_list_boolean.push(filterval[0]['name'] === element['pickup_location']);
202
+ }
203
+ if (filterval[0]['type'] === 'destination location') {
204
+ result_list_boolean.push(filterval[0]['name'] === element['delivery_location']);
205
+ }
206
+ if (filterval[0]['type'] === 'job') {
207
+ result_list_boolean.push(filterval[0]['name'] === element['order_number']);
208
+ }
209
+ if (filterval[0]['type'] === 'Route name') {
210
+ result_list_boolean.push(filterval[0]['name'] === element['route_name']);
211
+ }
212
+ if (filterval[0]['type'] === 'Driver') {
213
+ const index = (_a = element.driver_list) === null || _a === void 0 ? void 0 : _a.findIndex(ele => { return filterval[0]['name'] === ele['driver_name']; });
214
+ if (index !== -1)
215
+ result_list_boolean.push(true);
216
+ }
217
+ if (filterval[0]['type'] === 'Trucking Company') {
218
+ const index = (_b = element.driver_list) === null || _b === void 0 ? void 0 : _b.findIndex(ele => { return filterval[0]['name'] === ele['trucking_company']; });
219
+ if (index !== -1)
220
+ result_list_boolean.push(true);
221
+ }
222
+ }
223
+ if (result_list_boolean.length > 0) {
224
+ return result_list_boolean.reduce((prev, curr) => prev && curr);
225
+ }
226
+ return false;
227
+ });
228
+ }
229
+ clearOptions() {
230
+ this.pickupOptions = [];
231
+ this.destOptions = [];
232
+ this.ownerOptions = [];
233
+ this.customerOptions = [];
234
+ this.unitOptions = [];
235
+ this.materialOptions = [];
236
+ this.jcodeOptions = [];
237
+ this.routeNameOptions = [];
238
+ }
239
+ setdictValue(key, value) {
240
+ this.dict.set(key, value);
241
+ }
242
+ getdictValue(key) {
243
+ return JSON.parse(this.dict.get(key));
244
+ }
245
+ removedictValue(key) {
246
+ this.dict.delete(key);
247
+ }
248
+ conveySearchIcon(value) {
249
+ if (value && typeof (value) !== 'object')
250
+ return true;
251
+ return false;
252
+ }
253
+ fetchUnitsList() {
254
+ return new Promise((resolve, reject) => {
255
+ if (!this.unitsList) {
256
+ this.getData('unit/list/view').subscribe((res) => {
257
+ if (res) {
258
+ this.unitsList = res.data;
259
+ resolve(this.unitsList);
260
+ }
261
+ });
262
+ }
263
+ else {
264
+ resolve(this.unitsList);
265
+ }
266
+ });
267
+ }
268
+ fetchMaterialsList() {
269
+ return new Promise((resolve, reject) => {
270
+ if (!this.materialsList) {
271
+ this.getData('material/list/view').subscribe(((res) => {
272
+ res.data.sort((a, b) => a.material.localeCompare(b.material));
273
+ this.materialsList = res.data;
274
+ resolve(this.materialsList);
275
+ }));
276
+ }
277
+ else {
278
+ resolve(this.materialsList);
279
+ }
280
+ });
281
+ }
282
+ fetchCustomersList() {
283
+ return new Promise((resolve, reject) => {
284
+ if (!this.customersList) {
285
+ this.getData('company/list/view').subscribe((res) => {
286
+ if (res) {
287
+ this.customersList = res.data;
288
+ resolve(this.customersList);
289
+ }
290
+ });
291
+ }
292
+ else {
293
+ resolve(this.customersList);
294
+ }
295
+ });
296
+ }
297
+ }
298
+ UtilsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UtilsService, deps: [{ token: i1.HttpClient }, { token: i2.MatSnackBar }, { token: 'memberData' }], target: i0.ɵɵFactoryTarget.Injectable });
299
+ UtilsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UtilsService, providedIn: 'root' });
300
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UtilsService, decorators: [{
301
+ type: Injectable,
302
+ args: [{ providedIn: 'root' }]
303
+ }], ctorParameters: function () {
304
+ return [{ type: i1.HttpClient }, { type: i2.MatSnackBar }, { type: CoolmapConfigModel, decorators: [{
305
+ type: Inject,
306
+ args: ['memberData']
307
+ }] }];
308
308
  } });
309
309
 
310
- class CoolmapService {
311
- constructor(utils, eventManager, config) {
312
- this.utils = utils;
313
- this.eventManager = eventManager;
314
- this.config = config;
315
- this.markerOriginList = [];
316
- this.markerDestinationList = [];
317
- this.initiatecoolmap = new BehaviorSubject(true);
318
- this.reintiatecoolmap = this.initiatecoolmap.asObservable();
319
- this.bounds = new mapboxgl.LngLatBounds();
320
- this.originDestinationCordinates = [];
321
- this.customTopForCustomer = this.config.repository === 'customer' ? 65 : 0;
322
- this.eventManager.addGlobalEventListener('window', 'resize', this.onResize.bind(this));
323
- this.windowActualHeightWidth = { availHeight: 0 };
324
- }
325
- initiateMapForAddRoute(el) {
326
- return new Promise((resolve, reject) => {
327
- if (this.map)
328
- this.map.remove();
329
- this.map = new mapboxgl.Map({
330
- accessToken: this.config.mapboxAccessToken,
331
- container: el,
332
- style: this.config.mapboxStyle,
333
- center: [-77.036873, 38.907192],
334
- zoom: 10, bearing: 0, pitch: 65, interactive: true,
335
- });
336
- this.map.once('load', (res) => {
337
- resolve(res);
338
- });
339
- });
340
- }
341
- // Below method Load route with animation
342
- loadMapProperty(pinRouteGeojson, index, unit, route, bottom) {
343
- return new Promise((resolve, reject) => {
344
- let origin = pinRouteGeojson.features[0].geometry.coordinates[0];
345
- const linecolor = (unit === 'Ton') ? '#ff7272' : (unit === 'Load') ? '#a3c52e' : '#ae23d1';
346
- let destination = pinRouteGeojson.features[0].geometry.coordinates[pinRouteGeojson.features[0].geometry.coordinates.length - 1];
347
- this.extendBound(pinRouteGeojson.features[0].geometry.coordinates, true).then((res) => {
348
- const point = {
349
- 'type': 'FeatureCollection',
350
- 'features': [
351
- { 'type': 'Feature', 'properties': {}, 'geometry': { 'type': 'Point', 'coordinates': origin } }
352
- ]
353
- };
354
- const lineDistance = turf.length(pinRouteGeojson.features[0]);
355
- const arc = [];
356
- const steps = 10 * pinRouteGeojson.features[0].geometry.coordinates.length;
357
- for (let i = 0; i < lineDistance; i += lineDistance / steps) {
358
- const segment = turf.along(pinRouteGeojson.features[0], i);
359
- arc.push(segment.geometry.coordinates);
360
- }
361
- pinRouteGeojson.features[0].geometry.coordinates = arc;
362
- const pinRoute = pinRouteGeojson.features[0].geometry.coordinates;
363
- const marker = new mapboxgl.Marker(document.createElement('div'))
364
- .setLngLat(pinRoute[0]).addTo(this.map).togglePopup();
365
- if (this.map.getSource(`line${index}`)) {
366
- this.removeRouteAndMarker(index).then(() => { });
367
- }
368
- this.map.addSource(`line${index}`, { type: 'geojson', lineMetrics: true, data: pinRouteGeojson });
369
- this.map.addLayer({
370
- type: 'line',
371
- source: `line${index}`,
372
- id: `line${index}`,
373
- paint: {
374
- 'line-width': 2,
375
- 'line-gradient': [
376
- 'interpolate',
377
- ['linear'],
378
- ['line-progress'],
379
- 0, unit === 'Ton' ? '#d7f7e4' : unit === 'Load' ? '#c9d8f5' : '#f5dcc1',
380
- 1, unit === 'Ton' ? '#ff7272' : unit === 'Load' ? '#a3c52e' : '#ae23d1',
381
- ]
382
- },
383
- layout: { 'line-cap': 'round', 'line-join': 'round' }
384
- });
385
- const dataSetForMap = {
386
- counter: 0, pinRouteGeojson, steps,
387
- point, pointId: `point${index}`,
388
- marker, pinRoute, lineId: `line${index}`, index,
389
- origin, destination, lineDistance,
390
- linecolor, route, isViewRoute: true
391
- };
392
- this.createMarker(dataSetForMap);
393
- this.map.on('mouseenter', `line${index}`, (e) => {
394
- this.map.setPaintProperty(`line${index}`, 'line-width', 5);
395
- this.map.setPaintProperty(`line${index}`, 'line-opacity', 1);
396
- const datasetForPopup = {
397
- coordinate: [e.lngLat.lng, e.lngLat.lat],
398
- pickup: route.pickup_location ? route.pickup_location : '',
399
- drop: route.delivery_location ? route.delivery_location : '',
400
- routeType: route.project ? 'Project' : 'Route',
401
- title: route.project ? route.project : route.route_name ? route.route_name : '',
402
- material: route.material ? route.material : '',
403
- type: route.unit ? route.unit : ''
404
- };
405
- this.createPopup(datasetForPopup);
406
- });
407
- this.map.on('mouseleave', `line${index}`, (e) => {
408
- this.map.setPaintProperty(`line${index}`, 'line-width', 2);
409
- if (this.popup) {
410
- this.popup.remove();
411
- }
412
- });
413
- });
414
- this.map.once('idle', (res) => {
415
- resolve(true);
416
- });
417
- });
418
- }
419
- // Below method Load route without animation
420
- drawLine(cordinates, index, route, enablefitbound, routeType) {
421
- let linecolor;
422
- let origin = cordinates[0];
423
- let destination = cordinates[cordinates.length - 1];
424
- if (origin[0] && origin[1] && destination && destination[0] && destination[1]) {
425
- linecolor = this.provideLineColor(route['unit'], routeType);
426
- if (enablefitbound) {
427
- const padding = {
428
- top: this.padding.top + this.customTopForCustomer, bottom: this.padding.bottom + (this.windowActualHeightWidth.availHeight - (window.innerHeight - 65)),
429
- left: this.padding.left, right: this.padding.right
430
- };
431
- this.map.fitBounds([origin, destination], { padding, pitch: 65 }, { fitboundCompleteJob: true });
432
- }
433
- if (this.map.getSource(`route-source-for-job-code${index}`)) {
434
- this.removeRouteAndMarker(index).then(() => { });
435
- }
436
- this.map.addSource(`route-source-for-job-code${index}`, {
437
- 'type': 'geojson',
438
- 'data': { 'type': 'Feature', 'properties': {}, 'geometry': { 'type': 'LineString', 'coordinates': cordinates } }
439
- });
440
- this.map.addLayer({
441
- 'id': `route-for-job-code${index}`, 'type': 'line', 'source': `route-source-for-job-code${index}`,
442
- paint: { 'line-color': linecolor, 'line-width': 2 },
443
- layout: { 'line-cap': 'round', 'line-join': 'round' }
444
- });
445
- const dataSetForMap = {
446
- origin, destination, index, linecolor, route
447
- };
448
- this.createMarker(dataSetForMap);
449
- this.map.on('mouseenter', `route-for-job-code${index}`, (e) => {
450
- if (this.popup) {
451
- this.popup.remove();
452
- }
453
- this.map.setPaintProperty(`route-for-job-code${index}`, 'line-width', 5);
454
- this.map.setPaintProperty(`route-for-job-code${index}`, 'line-opacity', 1);
455
- const datasetForPopup = {
456
- coordinate: [e.lngLat.lng, e.lngLat.lat],
457
- pickup: route.pickup_location ? route.pickup_location : '',
458
- drop: route.delivery_location ? route.delivery_location : '',
459
- jobCode: route.project ? route.order_number : null,
460
- customer: route.project ? route.customer_name : null,
461
- routeType: route.project ? 'Project' : 'Route',
462
- title: route.project ? route.project : route.route_name ? route.route_name : '',
463
- material: route.material ? route.material : '',
464
- type: route.unit ? route.unit : ''
465
- };
466
- this.createPopup(datasetForPopup);
467
- });
468
- this.map.on('mouseleave', `route-for-job-code${index}`, (e) => {
469
- this.map.setPaintProperty(`route-for-job-code${index}`, 'line-width', 2);
470
- if (this.popup) {
471
- this.popup.remove();
472
- }
473
- });
474
- }
475
- }
476
- provideLineColor(unitType, type) {
477
- let checkType = (type && !['jobrouteList', 'addroute'].includes(type)) ? true : false;
478
- let color;
479
- switch (unitType) {
480
- case "Ton":
481
- color = checkType ? '#39c471' : '#ff7272';
482
- break;
483
- case "Load":
484
- color = checkType ? '#326ad3' : '#a3c52e';
485
- break;
486
- case "Hourly":
487
- color = checkType ? '#ffad56' : '#ae23d1';
488
- break;
489
- }
490
- return color;
491
- }
492
- showRoutePopup(arcDetails, event, isViewRoute) {
493
- if (this.popup) {
494
- this.popup.remove();
495
- this.map.setPaintProperty(`${isViewRoute ? 'line' : 'route-for-job-code'}${arcDetails.layer.props.data.index}`, 'line-width', 2);
496
- }
497
- if (arcDetails.color && this.map.getLayoutProperty(arcDetails.layer.id, 'visibility') !== 'none') {
498
- this.map.setPaintProperty(`${isViewRoute ? 'line' : 'route-for-job-code'}${arcDetails.layer.props.data.index}`, 'line-width', 5);
499
- this.map.setPaintProperty(`${isViewRoute ? 'line' : 'route-for-job-code'}${arcDetails.layer.props.data.index}`, 'line-opacity', 1);
500
- const datasetForPopup = {
501
- coordinate: arcDetails.coordinate,
502
- pickup: arcDetails.layer.props.data.route.pickup_location ? arcDetails.layer.props.data.route.pickup_location : '',
503
- drop: arcDetails.layer.props.data.route.delivery_location ? arcDetails.layer.props.data.route.delivery_location : '',
504
- jobCode: arcDetails.layer.props.data.route.project ? arcDetails.layer.props.data.route.order_number : '',
505
- customer: arcDetails.layer.props.data.route.project ? arcDetails.layer.props.data.route.customer_name : '',
506
- routeType: arcDetails.layer.props.data.route.project ? 'Project' : 'Route',
507
- title: arcDetails.layer.props.data.route.project ? arcDetails.layer.props.data.route.project : arcDetails.layer.props.data.route.route_name ? arcDetails.layer.props.data.route.route_name : '',
508
- material: arcDetails.layer.props.data.route.material ? arcDetails.layer.props.data.route.material : '',
509
- type: arcDetails.layer.props.data.route.unit ? arcDetails.layer.props.data.route.unit : ''
510
- };
511
- this.createPopup(datasetForPopup);
512
- }
513
- }
514
- createPopup(datasetForPopup) {
515
- this.popup = new mapboxgl.Popup({
516
- closeButton: false,
517
- closeOnClick: false,
518
- closeOnMove: true,
519
- anchor: 'bottom-left'
520
- });
521
- this.popup.setLngLat(datasetForPopup.coordinate)
522
- .setHTML(`
523
- <div class="destination">
524
- <div class="duration">
525
- <p class="pickprt"><b>Pickup Location:</b> ${datasetForPopup.pickup}</p>
526
- <p class="dropprt"><b>Drop Location:</b> ${datasetForPopup.drop}</p>
527
- </div>
528
- ${datasetForPopup.jobCode ? '<span><b>Job Code:</b> ' + datasetForPopup.jobCode + '</span>' : ''}
529
- ${datasetForPopup.customer ? '<span><b>Customer:</b> ' + datasetForPopup.customer + '</span>' : ''}
530
- <span><b>${datasetForPopup.routeType} Name:</b> ${datasetForPopup.title}</span>
531
- <span><b>Material:</b> ${datasetForPopup.material}</span>
532
- <span><b>Type:</b> ${datasetForPopup.type}</span>
533
- </div>
534
- `)
535
- .addTo(this.map);
536
- }
537
- hexToRGB(hex) {
538
- return hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (m, r, g, b) => '#' + r + r + g + g + b + b)
539
- .substring(1).match(/.{2}/g)
540
- .map(x => parseInt(x, 16));
541
- }
542
- createMarker(routeDetails) {
543
- var _a, _b;
544
- if (routeDetails.origin[0] && routeDetails.origin[1] && routeDetails.destination[0] && routeDetails.destination[1]) {
545
- const popup = new mapboxgl.Popup({ closeButton: false }).setHTML('<b>Pickup: </b>' + ((_a = routeDetails.route) === null || _a === void 0 ? void 0 : _a.pickup_location));
546
- const popupForDestination = new mapboxgl.Popup({ closeButton: false })
547
- .setHTML('<b>Delivery: </b>' + ((_b = routeDetails.route) === null || _b === void 0 ? void 0 : _b.delivery_location));
548
- const el = document.createElement('div');
549
- el.className = 'marker';
550
- el.innerHTML = `<span class='markerPointer' style='background:${routeDetails.linecolor}'><b>P</b><span class='markerSpan' style='border-top: 10px solid ${routeDetails.linecolor}'></span></span>`;
551
- const originMarker = new mapboxgl.Marker(el)
552
- .setPopup(popup).setLngLat(routeDetails.origin).addTo(this.map);
553
- originMarker.getElement().addEventListener('mouseenter', () => originMarker.togglePopup());
554
- originMarker.getElement().addEventListener('mouseleave', () => originMarker.togglePopup());
555
- const elementForDestination = document.createElement('div');
556
- elementForDestination.className = 'marker';
557
- elementForDestination.innerHTML = `<span class='markerPointer' style='background:${routeDetails.linecolor}'><b>D</b><span class='markerSpan' style='border-top: 10px solid ${routeDetails.linecolor}'></span></span>`;
558
- const destinationMarker = new mapboxgl.Marker(elementForDestination).setPopup(popupForDestination).setLngLat(routeDetails.destination).addTo(this.map);
559
- destinationMarker.getElement().addEventListener('mouseenter', () => destinationMarker.togglePopup());
560
- destinationMarker.getElement().addEventListener('mouseleave', () => destinationMarker.togglePopup());
561
- this.markerOriginList[routeDetails.index] = originMarker;
562
- this.markerDestinationList[routeDetails.index] = destinationMarker;
563
- const colorArray = this.hexToRGB(routeDetails.linecolor);
564
- const arcLayer = new MapboxLayer({
565
- id: 'arc-layer' + routeDetails.index,
566
- type: ArcLayer,
567
- pickable: true,
568
- data: { route: routeDetails.route, index: routeDetails.index },
569
- getWidth: 1,
570
- getSourcePosition: routeDetails.origin,
571
- getTargetPosition: routeDetails.destination,
572
- getTargetColor: [255, 255, 255],
573
- getSourceColor: [colorArray[0], colorArray[1], colorArray[2]],
574
- onHover: (info, event) => this.showRoutePopup(info, event, routeDetails.isViewRoute),
575
- });
576
- this.map.addLayer(arcLayer);
577
- }
578
- }
579
- removeRouteAndMarker(index) {
580
- return __awaiter(this, void 0, void 0, function* () {
581
- if (this.map) {
582
- this.map.getLayer(`arc-layer${index}`) ? this.map.removeLayer(`arc-layer${index}`) : '';
583
- this.map.getLayer(`line${index}`) ? this.map.removeLayer(`line${index}`) : '';
584
- this.map.getLayer(`custom_layer${index}`) ? this.map.removeLayer(`custom_layer${index}`) : '';
585
- this.map.getSource(`line${index}`) ? this.map.removeSource(`line${index}`) : '';
586
- this.map.getLayer(`route-for-job-code${index}`) ? this.map.removeLayer(`route-for-job-code${index}`) : '';
587
- this.map.getSource(`route-source-for-job-code${index}`) ? this.map.removeSource(`route-source-for-job-code${index}`) : '';
588
- this.findMarkerBound(index);
589
- this.markerOriginList[index] ? this.markerOriginList[index].remove() : '';
590
- this.markerDestinationList[index] ? this.markerDestinationList[index].remove() : '';
591
- yield true;
592
- }
593
- });
594
- }
595
- findMarkerBound(index) {
596
- const indexOfCordinates = this.originDestinationCordinates.findIndex((x) => { var _a, _b, _c, _d; return (x[0][0].toFixed(6) == ((_b = (_a = this.markerOriginList[index]) === null || _a === void 0 ? void 0 : _a.getLngLat()) === null || _b === void 0 ? void 0 : _b.lng.toFixed(6))) && (x[0][1].toFixed(6) == ((_d = (_c = this.markerOriginList[index]) === null || _c === void 0 ? void 0 : _c.getLngLat()) === null || _d === void 0 ? void 0 : _d.lat.toFixed(6))); });
597
- if (indexOfCordinates >= 0) {
598
- this.originDestinationCordinates.splice(indexOfCordinates, 1);
599
- }
600
- }
601
- filterRoute(ID, visibility, showAllFitbound) {
602
- return __awaiter(this, void 0, void 0, function* () {
603
- if (ID) {
604
- if (this.map.getLayer(`route-for-job-code${ID}`)) {
605
- this.map.setLayoutProperty(`route-for-job-code${ID}`, 'visibility', visibility);
606
- const originM = this.markerOriginList[ID].getElement();
607
- originM.style.display = ((visibility === 'visible') ? 'block' : visibility);
608
- const destinationM = this.markerDestinationList[ID].getElement();
609
- destinationM.style.display = ((visibility === 'visible') ? 'block' : visibility);
610
- if (visibility === 'none' && showAllFitbound) {
611
- this.findMarkerBound(ID);
612
- this.extendReBound();
613
- }
614
- }
615
- if (this.map.getLayer(`arc-layer${ID}`)) {
616
- this.map.setLayoutProperty(`arc-layer${ID}`, 'visibility', visibility);
617
- }
618
- }
619
- yield true;
620
- });
621
- }
622
- extendBound(route, showAllFitbound) {
623
- return new Promise((resolve, reject) => {
624
- if (route) {
625
- if (typeof route === 'string') {
626
- let path = route.split(';');
627
- path = path.map((ele) => { return ele = this.formateLatLong(ele); });
628
- path.forEach((ele, index) => {
629
- if (ele.length === 1)
630
- path.splice(index, 1);
631
- });
632
- route = path;
633
- }
634
- if (route[0][0] && route[0][1] && route[route.length - 1][0] && route[route.length - 1][1]) {
635
- this.originDestinationCordinates.push(route);
636
- route.map((item) => {
637
- this.bounds.extend(item);
638
- });
639
- }
640
- }
641
- if (showAllFitbound) {
642
- const padding = { top: this.padding.top + this.customTopForCustomer, bottom: (this.padding.bottom + (this.windowActualHeightWidth.availHeight - (window.innerHeight - 65))), left: this.padding.left, right: this.padding.right };
643
- setTimeout(() => {
644
- if (showAllFitbound && (Object.keys(this.bounds).length > 0))
645
- this.map.fitBounds(this.bounds, { padding, pitch: 65 }, { fitboundComplete: true });
646
- }, 100);
647
- this.map.once('moveend', (event) => {
648
- if (event.fitboundComplete) {
649
- resolve(true);
650
- }
651
- });
652
- }
653
- });
654
- }
655
- extendReBound(bottom) {
656
- return new Promise((resolve, reject) => {
657
- this.bounds = new mapboxgl.LngLatBounds();
658
- if (this.originDestinationCordinates.length >= 0) {
659
- this.originDestinationCordinates.map((item, index) => {
660
- item.map((route) => {
661
- this.bounds.extend(route);
662
- });
663
- if (index === (this.originDestinationCordinates.length - 1)) {
664
- const padding = { top: this.padding.top + this.customTopForCustomer, bottom: (this.padding.bottom + (this.windowActualHeightWidth.availHeight - (window.innerHeight - 65))), left: this.padding.left, right: this.padding.right };
665
- setTimeout(() => {
666
- if (this.originDestinationCordinates.length > 0)
667
- this.map.fitBounds(this.bounds, { padding, pitch: 65 });
668
- }, 500);
669
- resolve(true);
670
- }
671
- });
672
- }
673
- else {
674
- resolve(true);
675
- }
676
- });
677
- }
678
- plotRoute(route, i, type, enablefitbound, showAllFitbound) {
679
- return new Promise((resolve, reject) => {
680
- let param = {};
681
- if (['jobcode'].includes(type)) {
682
- param['job'] = route['job_id'];
683
- this.utils.postDataWithRestUrl('schedule/job/path', param).subscribe((res) => {
684
- if (res['data']['route']) {
685
- let path = res['data']['route'].split(';');
686
- path = path.map((ele) => { return ele = this.formateLatLong(ele); });
687
- path.forEach((ele, index) => {
688
- if (ele.length === 1)
689
- path.splice(index, 1);
690
- });
691
- route['path'] = path;
692
- this.extendBound(route['path'], showAllFitbound);
693
- if (route['path'] && route['path'].length > 0)
694
- this.drawLine(route['path'], i, route, enablefitbound, type);
695
- route['index'] = i;
696
- }
697
- else {
698
- this.extendBound(null, showAllFitbound);
699
- }
700
- resolve(true);
701
- }, (err) => {
702
- if (err) {
703
- reject(false);
704
- }
705
- });
706
- }
707
- else if (['jobrouteList', 'addroute'].includes(type)) {
708
- if (route['path'] && route['path'].length > 0) {
709
- let path = route['path'].split(';');
710
- path = path.map((ele) => { return ele = this.formateLatLong(ele); });
711
- path.forEach((ele, index) => {
712
- if (ele.length === 1)
713
- path.splice(index, 1);
714
- });
715
- this.extendBound(path, showAllFitbound);
716
- this.drawLine(path, i, route, enablefitbound, type);
717
- }
718
- ;
719
- }
720
- });
721
- }
722
- clearBound() { this.bounds = new mapboxgl.LngLatBounds(); this.originDestinationCordinates = []; this.clearPadding(); }
723
- formateLatLong(latlong) { return latlong ? latlong.split(',').map(x => +x).reverse() : null; }
724
- clearBoundWithCordinates() {
725
- this.bounds = new mapboxgl.LngLatBounds();
726
- this.originDestinationCordinates = [];
727
- }
728
- onResize(event) {
729
- if (!this.bounds.isEmpty()) {
730
- this.windowActualHeightWidth.availHeight = (window.innerHeight > window.screen.availHeight) ? window.innerHeight : window.screen.availHeight;
731
- setTimeout(() => {
732
- this.map.fitBounds(this.bounds, { padding: { top: this.padding.top + this.customTopForCustomer, bottom: this.padding.bottom + (this.windowActualHeightWidth.availHeight - (event.target.innerHeight - 65)), left: this.padding.left, right: this.padding.right }, pitch: 65 });
733
- }, 500);
734
- }
735
- }
736
- setWindowHeight(screen) {
737
- this.windowActualHeightWidth.availHeight = screen;
738
- }
739
- setPadding(padding) { this.padding = padding; }
740
- clearPadding() { this.padding = null; }
741
- removeJobFromMap(data) {
742
- data.map((ele, index) => {
743
- const id = (ele['job_id'] ? ele['job_id'] : ele['route_id']);
744
- this.removeRouteAndMarker(id);
745
- if (index === (data.length - 1)) {
746
- this.extendReBound();
747
- }
748
- });
749
- }
750
- }
751
- CoolmapService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CoolmapService, deps: [{ token: UtilsService }, { token: i2$1.EventManager }, { token: 'memberData' }], target: i0.ɵɵFactoryTarget.Injectable });
752
- CoolmapService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CoolmapService, providedIn: 'root' });
753
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CoolmapService, decorators: [{
754
- type: Injectable,
755
- args: [{ providedIn: 'root' }]
756
- }], ctorParameters: function () {
757
- return [{ type: UtilsService }, { type: i2$1.EventManager }, { type: CoolmapConfigModel, decorators: [{
758
- type: Inject,
759
- args: ['memberData']
760
- }] }];
310
+ class CoolmapService {
311
+ constructor(utils, eventManager, config) {
312
+ this.utils = utils;
313
+ this.eventManager = eventManager;
314
+ this.config = config;
315
+ this.markerOriginList = [];
316
+ this.markerDestinationList = [];
317
+ this.initiatecoolmap = new BehaviorSubject(true);
318
+ this.reintiatecoolmap = this.initiatecoolmap.asObservable();
319
+ this.bounds = new mapboxgl.LngLatBounds();
320
+ this.originDestinationCordinates = [];
321
+ this.customTopForCustomer = this.config.repository === 'customer' ? 65 : 0;
322
+ this.eventManager.addGlobalEventListener('window', 'resize', this.onResize.bind(this));
323
+ this.windowActualHeightWidth = { availHeight: 0 };
324
+ }
325
+ initiateMapForAddRoute(el) {
326
+ return new Promise((resolve, reject) => {
327
+ console.log(this.config);
328
+ if (this.map)
329
+ this.map.remove();
330
+ this.map = new mapboxgl.Map({
331
+ accessToken: this.config.mapboxAccessToken,
332
+ container: el,
333
+ style: this.config.mapboxStyle,
334
+ center: [-77.036873, 38.907192],
335
+ zoom: 10, bearing: 0, pitch: 65, interactive: true,
336
+ });
337
+ this.map.once('load', (res) => {
338
+ resolve(res);
339
+ });
340
+ });
341
+ }
342
+ // Below method Load route with animation
343
+ loadMapProperty(pinRouteGeojson, index, unit, route, bottom) {
344
+ return new Promise((resolve, reject) => {
345
+ let origin = pinRouteGeojson.features[0].geometry.coordinates[0];
346
+ const linecolor = (unit === 'Ton') ? '#ff7272' : (unit === 'Load') ? '#a3c52e' : '#ae23d1';
347
+ let destination = pinRouteGeojson.features[0].geometry.coordinates[pinRouteGeojson.features[0].geometry.coordinates.length - 1];
348
+ this.extendBound(pinRouteGeojson.features[0].geometry.coordinates, true).then((res) => {
349
+ const point = {
350
+ 'type': 'FeatureCollection',
351
+ 'features': [
352
+ { 'type': 'Feature', 'properties': {}, 'geometry': { 'type': 'Point', 'coordinates': origin } }
353
+ ]
354
+ };
355
+ const lineDistance = turf.length(pinRouteGeojson.features[0]);
356
+ const arc = [];
357
+ const steps = 10 * pinRouteGeojson.features[0].geometry.coordinates.length;
358
+ for (let i = 0; i < lineDistance; i += lineDistance / steps) {
359
+ const segment = turf.along(pinRouteGeojson.features[0], i);
360
+ arc.push(segment.geometry.coordinates);
361
+ }
362
+ pinRouteGeojson.features[0].geometry.coordinates = arc;
363
+ const pinRoute = pinRouteGeojson.features[0].geometry.coordinates;
364
+ const marker = new mapboxgl.Marker(document.createElement('div'))
365
+ .setLngLat(pinRoute[0]).addTo(this.map).togglePopup();
366
+ if (this.map.getSource(`line${index}`)) {
367
+ this.removeRouteAndMarker(index).then(() => { });
368
+ }
369
+ this.map.addSource(`line${index}`, { type: 'geojson', lineMetrics: true, data: pinRouteGeojson });
370
+ this.map.addLayer({
371
+ type: 'line',
372
+ source: `line${index}`,
373
+ id: `line${index}`,
374
+ paint: {
375
+ 'line-width': 2,
376
+ 'line-gradient': [
377
+ 'interpolate',
378
+ ['linear'],
379
+ ['line-progress'],
380
+ 0, unit === 'Ton' ? '#d7f7e4' : unit === 'Load' ? '#c9d8f5' : '#f5dcc1',
381
+ 1, unit === 'Ton' ? '#ff7272' : unit === 'Load' ? '#a3c52e' : '#ae23d1',
382
+ ]
383
+ },
384
+ layout: { 'line-cap': 'round', 'line-join': 'round' }
385
+ });
386
+ const dataSetForMap = {
387
+ counter: 0, pinRouteGeojson, steps,
388
+ point, pointId: `point${index}`,
389
+ marker, pinRoute, lineId: `line${index}`, index,
390
+ origin, destination, lineDistance,
391
+ linecolor, route, isViewRoute: true
392
+ };
393
+ this.createMarker(dataSetForMap);
394
+ this.map.on('mouseenter', `line${index}`, (e) => {
395
+ this.map.setPaintProperty(`line${index}`, 'line-width', 5);
396
+ this.map.setPaintProperty(`line${index}`, 'line-opacity', 1);
397
+ const datasetForPopup = {
398
+ coordinate: [e.lngLat.lng, e.lngLat.lat],
399
+ pickup: route.pickup_location ? route.pickup_location : '',
400
+ drop: route.delivery_location ? route.delivery_location : '',
401
+ routeType: route.project ? 'Project' : 'Route',
402
+ title: route.project ? route.project : route.route_name ? route.route_name : '',
403
+ material: route.material ? route.material : '',
404
+ type: route.unit ? route.unit : ''
405
+ };
406
+ this.createPopup(datasetForPopup);
407
+ });
408
+ this.map.on('mouseleave', `line${index}`, (e) => {
409
+ this.map.setPaintProperty(`line${index}`, 'line-width', 2);
410
+ if (this.popup) {
411
+ this.popup.remove();
412
+ }
413
+ });
414
+ });
415
+ this.map.once('idle', (res) => {
416
+ resolve(true);
417
+ });
418
+ });
419
+ }
420
+ // Below method Load route without animation
421
+ drawLine(cordinates, index, route, enablefitbound, routeType) {
422
+ let linecolor;
423
+ let origin = cordinates[0];
424
+ let destination = cordinates[cordinates.length - 1];
425
+ if (origin[0] && origin[1] && destination && destination[0] && destination[1]) {
426
+ linecolor = this.provideLineColor(route['unit'], routeType);
427
+ if (enablefitbound) {
428
+ const padding = {
429
+ top: this.padding.top + this.customTopForCustomer, bottom: this.padding.bottom + (this.windowActualHeightWidth.availHeight - (window.innerHeight - 65)),
430
+ left: this.padding.left, right: this.padding.right
431
+ };
432
+ this.map.fitBounds([origin, destination], { padding, pitch: 65 }, { fitboundCompleteJob: true });
433
+ }
434
+ if (this.map.getSource(`route-source-for-job-code${index}`)) {
435
+ this.removeRouteAndMarker(index).then(() => { });
436
+ }
437
+ this.map.addSource(`route-source-for-job-code${index}`, {
438
+ 'type': 'geojson',
439
+ 'data': { 'type': 'Feature', 'properties': {}, 'geometry': { 'type': 'LineString', 'coordinates': cordinates } }
440
+ });
441
+ this.map.addLayer({
442
+ 'id': `route-for-job-code${index}`, 'type': 'line', 'source': `route-source-for-job-code${index}`,
443
+ paint: { 'line-color': linecolor, 'line-width': 2 },
444
+ layout: { 'line-cap': 'round', 'line-join': 'round' }
445
+ });
446
+ const dataSetForMap = {
447
+ origin, destination, index, linecolor, route
448
+ };
449
+ this.createMarker(dataSetForMap);
450
+ this.map.on('mouseenter', `route-for-job-code${index}`, (e) => {
451
+ if (this.popup) {
452
+ this.popup.remove();
453
+ }
454
+ this.map.setPaintProperty(`route-for-job-code${index}`, 'line-width', 5);
455
+ this.map.setPaintProperty(`route-for-job-code${index}`, 'line-opacity', 1);
456
+ const datasetForPopup = {
457
+ coordinate: [e.lngLat.lng, e.lngLat.lat],
458
+ pickup: route.pickup_location ? route.pickup_location : '',
459
+ drop: route.delivery_location ? route.delivery_location : '',
460
+ jobCode: route.project ? route.order_number : null,
461
+ customer: route.project ? route.customer_name : null,
462
+ routeType: route.project ? 'Project' : 'Route',
463
+ title: route.project ? route.project : route.route_name ? route.route_name : '',
464
+ material: route.material ? route.material : '',
465
+ type: route.unit ? route.unit : ''
466
+ };
467
+ this.createPopup(datasetForPopup);
468
+ });
469
+ this.map.on('mouseleave', `route-for-job-code${index}`, (e) => {
470
+ this.map.setPaintProperty(`route-for-job-code${index}`, 'line-width', 2);
471
+ if (this.popup) {
472
+ this.popup.remove();
473
+ }
474
+ });
475
+ }
476
+ }
477
+ provideLineColor(unitType, type) {
478
+ let checkType = (type && !['jobrouteList', 'addroute'].includes(type)) ? true : false;
479
+ let color;
480
+ switch (unitType) {
481
+ case "Ton":
482
+ color = checkType ? '#39c471' : '#ff7272';
483
+ break;
484
+ case "Load":
485
+ color = checkType ? '#326ad3' : '#a3c52e';
486
+ break;
487
+ case "Hourly":
488
+ color = checkType ? '#ffad56' : '#ae23d1';
489
+ break;
490
+ }
491
+ return color;
492
+ }
493
+ showRoutePopup(arcDetails, event, isViewRoute) {
494
+ if (this.popup) {
495
+ this.popup.remove();
496
+ this.map.setPaintProperty(`${isViewRoute ? 'line' : 'route-for-job-code'}${arcDetails.layer.props.data.index}`, 'line-width', 2);
497
+ }
498
+ if (arcDetails.color && this.map.getLayoutProperty(arcDetails.layer.id, 'visibility') !== 'none') {
499
+ this.map.setPaintProperty(`${isViewRoute ? 'line' : 'route-for-job-code'}${arcDetails.layer.props.data.index}`, 'line-width', 5);
500
+ this.map.setPaintProperty(`${isViewRoute ? 'line' : 'route-for-job-code'}${arcDetails.layer.props.data.index}`, 'line-opacity', 1);
501
+ const datasetForPopup = {
502
+ coordinate: arcDetails.coordinate,
503
+ pickup: arcDetails.layer.props.data.route.pickup_location ? arcDetails.layer.props.data.route.pickup_location : '',
504
+ drop: arcDetails.layer.props.data.route.delivery_location ? arcDetails.layer.props.data.route.delivery_location : '',
505
+ jobCode: arcDetails.layer.props.data.route.project ? arcDetails.layer.props.data.route.order_number : '',
506
+ customer: arcDetails.layer.props.data.route.project ? arcDetails.layer.props.data.route.customer_name : '',
507
+ routeType: arcDetails.layer.props.data.route.project ? 'Project' : 'Route',
508
+ title: arcDetails.layer.props.data.route.project ? arcDetails.layer.props.data.route.project : arcDetails.layer.props.data.route.route_name ? arcDetails.layer.props.data.route.route_name : '',
509
+ material: arcDetails.layer.props.data.route.material ? arcDetails.layer.props.data.route.material : '',
510
+ type: arcDetails.layer.props.data.route.unit ? arcDetails.layer.props.data.route.unit : ''
511
+ };
512
+ this.createPopup(datasetForPopup);
513
+ }
514
+ }
515
+ createPopup(datasetForPopup) {
516
+ this.popup = new mapboxgl.Popup({
517
+ closeButton: false,
518
+ closeOnClick: false,
519
+ closeOnMove: true,
520
+ anchor: 'bottom-left'
521
+ });
522
+ this.popup.setLngLat(datasetForPopup.coordinate)
523
+ .setHTML(`
524
+ <div class="destination">
525
+ <div class="duration">
526
+ <p class="pickprt"><b>Pickup Location:</b> ${datasetForPopup.pickup}</p>
527
+ <p class="dropprt"><b>Drop Location:</b> ${datasetForPopup.drop}</p>
528
+ </div>
529
+ ${datasetForPopup.jobCode ? '<span><b>Job Code:</b> ' + datasetForPopup.jobCode + '</span>' : ''}
530
+ ${datasetForPopup.customer ? '<span><b>Customer:</b> ' + datasetForPopup.customer + '</span>' : ''}
531
+ <span><b>${datasetForPopup.routeType} Name:</b> ${datasetForPopup.title}</span>
532
+ <span><b>Material:</b> ${datasetForPopup.material}</span>
533
+ <span><b>Type:</b> ${datasetForPopup.type}</span>
534
+ </div>
535
+ `)
536
+ .addTo(this.map);
537
+ }
538
+ hexToRGB(hex) {
539
+ return hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (m, r, g, b) => '#' + r + r + g + g + b + b)
540
+ .substring(1).match(/.{2}/g)
541
+ .map(x => parseInt(x, 16));
542
+ }
543
+ createMarker(routeDetails) {
544
+ var _a, _b;
545
+ if (routeDetails.origin[0] && routeDetails.origin[1] && routeDetails.destination[0] && routeDetails.destination[1]) {
546
+ const popup = new mapboxgl.Popup({ closeButton: false }).setHTML('<b>Pickup: </b>' + ((_a = routeDetails.route) === null || _a === void 0 ? void 0 : _a.pickup_location));
547
+ const popupForDestination = new mapboxgl.Popup({ closeButton: false })
548
+ .setHTML('<b>Delivery: </b>' + ((_b = routeDetails.route) === null || _b === void 0 ? void 0 : _b.delivery_location));
549
+ const el = document.createElement('div');
550
+ el.className = 'marker';
551
+ el.innerHTML = `<span class='markerPointer' style='background:${routeDetails.linecolor}'><b>P</b><span class='markerSpan' style='border-top: 10px solid ${routeDetails.linecolor}'></span></span>`;
552
+ const originMarker = new mapboxgl.Marker(el)
553
+ .setPopup(popup).setLngLat(routeDetails.origin).addTo(this.map);
554
+ originMarker.getElement().addEventListener('mouseenter', () => originMarker.togglePopup());
555
+ originMarker.getElement().addEventListener('mouseleave', () => originMarker.togglePopup());
556
+ const elementForDestination = document.createElement('div');
557
+ elementForDestination.className = 'marker';
558
+ elementForDestination.innerHTML = `<span class='markerPointer' style='background:${routeDetails.linecolor}'><b>D</b><span class='markerSpan' style='border-top: 10px solid ${routeDetails.linecolor}'></span></span>`;
559
+ const destinationMarker = new mapboxgl.Marker(elementForDestination).setPopup(popupForDestination).setLngLat(routeDetails.destination).addTo(this.map);
560
+ destinationMarker.getElement().addEventListener('mouseenter', () => destinationMarker.togglePopup());
561
+ destinationMarker.getElement().addEventListener('mouseleave', () => destinationMarker.togglePopup());
562
+ this.markerOriginList[routeDetails.index] = originMarker;
563
+ this.markerDestinationList[routeDetails.index] = destinationMarker;
564
+ const colorArray = this.hexToRGB(routeDetails.linecolor);
565
+ const arcLayer = new MapboxLayer({
566
+ id: 'arc-layer' + routeDetails.index,
567
+ type: ArcLayer,
568
+ pickable: true,
569
+ data: { route: routeDetails.route, index: routeDetails.index },
570
+ getWidth: 1,
571
+ getSourcePosition: routeDetails.origin,
572
+ getTargetPosition: routeDetails.destination,
573
+ getTargetColor: [255, 255, 255],
574
+ getSourceColor: [colorArray[0], colorArray[1], colorArray[2]],
575
+ onHover: (info, event) => this.showRoutePopup(info, event, routeDetails.isViewRoute),
576
+ });
577
+ this.map.addLayer(arcLayer);
578
+ }
579
+ }
580
+ removeRouteAndMarker(index) {
581
+ return __awaiter(this, void 0, void 0, function* () {
582
+ if (this.map) {
583
+ this.map.getLayer(`arc-layer${index}`) ? this.map.removeLayer(`arc-layer${index}`) : '';
584
+ this.map.getLayer(`line${index}`) ? this.map.removeLayer(`line${index}`) : '';
585
+ this.map.getLayer(`custom_layer${index}`) ? this.map.removeLayer(`custom_layer${index}`) : '';
586
+ this.map.getSource(`line${index}`) ? this.map.removeSource(`line${index}`) : '';
587
+ this.map.getLayer(`route-for-job-code${index}`) ? this.map.removeLayer(`route-for-job-code${index}`) : '';
588
+ this.map.getSource(`route-source-for-job-code${index}`) ? this.map.removeSource(`route-source-for-job-code${index}`) : '';
589
+ this.findMarkerBound(index);
590
+ this.markerOriginList[index] ? this.markerOriginList[index].remove() : '';
591
+ this.markerDestinationList[index] ? this.markerDestinationList[index].remove() : '';
592
+ yield true;
593
+ }
594
+ });
595
+ }
596
+ findMarkerBound(index) {
597
+ const indexOfCordinates = this.originDestinationCordinates.findIndex((x) => { var _a, _b, _c, _d; return (x[0][0].toFixed(6) == ((_b = (_a = this.markerOriginList[index]) === null || _a === void 0 ? void 0 : _a.getLngLat()) === null || _b === void 0 ? void 0 : _b.lng.toFixed(6))) && (x[0][1].toFixed(6) == ((_d = (_c = this.markerOriginList[index]) === null || _c === void 0 ? void 0 : _c.getLngLat()) === null || _d === void 0 ? void 0 : _d.lat.toFixed(6))); });
598
+ if (indexOfCordinates >= 0) {
599
+ this.originDestinationCordinates.splice(indexOfCordinates, 1);
600
+ }
601
+ }
602
+ filterRoute(ID, visibility, showAllFitbound) {
603
+ return __awaiter(this, void 0, void 0, function* () {
604
+ if (ID) {
605
+ if (this.map.getLayer(`route-for-job-code${ID}`)) {
606
+ this.map.setLayoutProperty(`route-for-job-code${ID}`, 'visibility', visibility);
607
+ const originM = this.markerOriginList[ID].getElement();
608
+ originM.style.display = ((visibility === 'visible') ? 'block' : visibility);
609
+ const destinationM = this.markerDestinationList[ID].getElement();
610
+ destinationM.style.display = ((visibility === 'visible') ? 'block' : visibility);
611
+ if (visibility === 'none' && showAllFitbound) {
612
+ this.findMarkerBound(ID);
613
+ this.extendReBound();
614
+ }
615
+ }
616
+ if (this.map.getLayer(`arc-layer${ID}`)) {
617
+ this.map.setLayoutProperty(`arc-layer${ID}`, 'visibility', visibility);
618
+ }
619
+ }
620
+ yield true;
621
+ });
622
+ }
623
+ extendBound(route, showAllFitbound) {
624
+ return new Promise((resolve, reject) => {
625
+ if (route) {
626
+ if (typeof route === 'string') {
627
+ let path = route.split(';');
628
+ path = path.map((ele) => { return ele = this.formateLatLong(ele); });
629
+ path.forEach((ele, index) => {
630
+ if (ele.length === 1)
631
+ path.splice(index, 1);
632
+ });
633
+ route = path;
634
+ }
635
+ if (route[0][0] && route[0][1] && route[route.length - 1][0] && route[route.length - 1][1]) {
636
+ this.originDestinationCordinates.push(route);
637
+ route.map((item) => {
638
+ this.bounds.extend(item);
639
+ });
640
+ }
641
+ }
642
+ if (showAllFitbound) {
643
+ const padding = { top: this.padding.top + this.customTopForCustomer, bottom: (this.padding.bottom + (this.windowActualHeightWidth.availHeight - (window.innerHeight - 65))), left: this.padding.left, right: this.padding.right };
644
+ setTimeout(() => {
645
+ if (showAllFitbound && (Object.keys(this.bounds).length > 0))
646
+ this.map.fitBounds(this.bounds, { padding, pitch: 65 }, { fitboundComplete: true });
647
+ }, 100);
648
+ this.map.once('moveend', (event) => {
649
+ if (event.fitboundComplete) {
650
+ resolve(true);
651
+ }
652
+ });
653
+ }
654
+ });
655
+ }
656
+ extendReBound(bottom) {
657
+ return new Promise((resolve, reject) => {
658
+ this.bounds = new mapboxgl.LngLatBounds();
659
+ if (this.originDestinationCordinates.length >= 0) {
660
+ this.originDestinationCordinates.map((item, index) => {
661
+ item.map((route) => {
662
+ this.bounds.extend(route);
663
+ });
664
+ if (index === (this.originDestinationCordinates.length - 1)) {
665
+ const padding = { top: this.padding.top + this.customTopForCustomer, bottom: (this.padding.bottom + (this.windowActualHeightWidth.availHeight - (window.innerHeight - 65))), left: this.padding.left, right: this.padding.right };
666
+ setTimeout(() => {
667
+ if (this.originDestinationCordinates.length > 0)
668
+ this.map.fitBounds(this.bounds, { padding, pitch: 65 });
669
+ }, 500);
670
+ resolve(true);
671
+ }
672
+ });
673
+ }
674
+ else {
675
+ resolve(true);
676
+ }
677
+ });
678
+ }
679
+ plotRoute(route, i, type, enablefitbound, showAllFitbound) {
680
+ return new Promise((resolve, reject) => {
681
+ let param = {};
682
+ if (['jobcode'].includes(type)) {
683
+ param['job'] = route['job_id'];
684
+ this.utils.postDataWithRestUrl('schedule/job/path', param).subscribe((res) => {
685
+ if (res['data']['route']) {
686
+ let path = res['data']['route'].split(';');
687
+ path = path.map((ele) => { return ele = this.formateLatLong(ele); });
688
+ path.forEach((ele, index) => {
689
+ if (ele.length === 1)
690
+ path.splice(index, 1);
691
+ });
692
+ route['path'] = path;
693
+ this.extendBound(route['path'], showAllFitbound);
694
+ if (route['path'] && route['path'].length > 0)
695
+ this.drawLine(route['path'], i, route, enablefitbound, type);
696
+ route['index'] = i;
697
+ }
698
+ else {
699
+ this.extendBound(null, showAllFitbound);
700
+ }
701
+ resolve(true);
702
+ }, (err) => {
703
+ if (err) {
704
+ reject(false);
705
+ }
706
+ });
707
+ }
708
+ else if (['jobrouteList', 'addroute'].includes(type)) {
709
+ if (route['path'] && route['path'].length > 0) {
710
+ let path = route['path'].split(';');
711
+ path = path.map((ele) => { return ele = this.formateLatLong(ele); });
712
+ path.forEach((ele, index) => {
713
+ if (ele.length === 1)
714
+ path.splice(index, 1);
715
+ });
716
+ this.extendBound(path, showAllFitbound);
717
+ this.drawLine(path, i, route, enablefitbound, type);
718
+ }
719
+ ;
720
+ }
721
+ });
722
+ }
723
+ clearBound() { this.bounds = new mapboxgl.LngLatBounds(); this.originDestinationCordinates = []; this.clearPadding(); }
724
+ formateLatLong(latlong) { return latlong ? latlong.split(',').map(x => +x).reverse() : null; }
725
+ clearBoundWithCordinates() {
726
+ this.bounds = new mapboxgl.LngLatBounds();
727
+ this.originDestinationCordinates = [];
728
+ }
729
+ onResize(event) {
730
+ if (!this.bounds.isEmpty()) {
731
+ this.windowActualHeightWidth.availHeight = (window.innerHeight > window.screen.availHeight) ? window.innerHeight : window.screen.availHeight;
732
+ setTimeout(() => {
733
+ this.map.fitBounds(this.bounds, { padding: { top: this.padding.top + this.customTopForCustomer, bottom: this.padding.bottom + (this.windowActualHeightWidth.availHeight - (event.target.innerHeight - 65)), left: this.padding.left, right: this.padding.right }, pitch: 65 });
734
+ }, 500);
735
+ }
736
+ }
737
+ setWindowHeight(screen) {
738
+ this.windowActualHeightWidth.availHeight = screen;
739
+ }
740
+ setPadding(padding) { this.padding = padding; }
741
+ clearPadding() { this.padding = null; }
742
+ removeJobFromMap(data) {
743
+ data.map((ele, index) => {
744
+ const id = (ele['job_id'] ? ele['job_id'] : ele['route_id']);
745
+ this.removeRouteAndMarker(id);
746
+ if (index === (data.length - 1)) {
747
+ this.extendReBound();
748
+ }
749
+ });
750
+ }
751
+ }
752
+ CoolmapService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CoolmapService, deps: [{ token: UtilsService }, { token: i2$1.EventManager }, { token: 'memberData' }], target: i0.ɵɵFactoryTarget.Injectable });
753
+ CoolmapService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CoolmapService, providedIn: 'root' });
754
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CoolmapService, decorators: [{
755
+ type: Injectable,
756
+ args: [{ providedIn: 'root' }]
757
+ }], ctorParameters: function () {
758
+ return [{ type: UtilsService }, { type: i2$1.EventManager }, { type: CoolmapConfigModel, decorators: [{
759
+ type: Inject,
760
+ args: ['memberData']
761
+ }] }];
761
762
  } });
762
763
 
763
- /*
764
- * Public API Surface of coolmap-services
764
+ /*
765
+ * Public API Surface of coolmap-services
765
766
  */
766
767
 
767
- /**
768
- * Generated bundle index. Do not edit.
768
+ /**
769
+ * Generated bundle index. Do not edit.
769
770
  */
770
771
 
771
772
  export { CoolmapConfigModel, CoolmapService, DriverSmsCardEnum, DriversmsCardKey, EstinationData, EstinationEnum, JobCodeOverviewData, JobCodeOverviewEnum, PopupData, Route, UtilsService };