@aggdirect/coolmap-services 1.1.3 → 1.1.4

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