@aggdirect/coolmap-services 1.1.8 → 1.2.0

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,743 +9,769 @@ 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 = ['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 {
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 {
50
50
  }
51
51
 
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']
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
+ fetchMaterialsListForCustomer() {
280
+ return new Promise((resolve, reject) => {
281
+ if (!this.materialsList) {
282
+ this.getData('material/list/view').subscribe(((res) => {
283
+ let meterialListDetails = [];
284
+ res.data.map((item) => {
285
+ if (item.sub.length > 0) {
286
+ item.sub.map((subItem) => {
287
+ if (subItem.add_to_marketplace) {
288
+ subItem.material = item.material;
289
+ subItem.material_id = item.material_id;
290
+ subItem.label = item.material + ' | ' + subItem.sub_material;
291
+ meterialListDetails.push(subItem);
292
+ }
293
+ });
294
+ }
295
+ });
296
+ meterialListDetails.sort((a, b) => a.label.localeCompare(b.label));
297
+ this.materialsList = meterialListDetails;
298
+ resolve(this.materialsList);
299
+ }));
300
+ }
301
+ else {
302
+ resolve(this.materialsList);
303
+ }
304
+ });
305
+ }
306
+ fetchCustomersList() {
307
+ return new Promise((resolve, reject) => {
308
+ if (!this.customersList) {
309
+ this.getData('company/list/view').subscribe((res) => {
310
+ if (res) {
311
+ this.customersList = res.data;
312
+ resolve(this.customersList);
313
+ }
314
+ });
315
+ }
316
+ else {
317
+ resolve(this.customersList);
318
+ }
319
+ });
320
+ }
321
+ }
322
+ 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 });
323
+ UtilsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UtilsService, providedIn: 'root' });
324
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UtilsService, decorators: [{
325
+ type: Injectable,
326
+ args: [{ providedIn: 'root' }]
327
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: i2.MatSnackBar }, { type: CoolmapConfigModel, decorators: [{
328
+ type: Inject,
329
+ args: ['memberData']
303
330
  }] }]; } });
304
331
 
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
- console.log(this.config);
323
- if (this.map)
324
- this.map.remove();
325
- this.map = new mapboxgl.Map({
326
- accessToken: this.config.mapboxAccessToken,
327
- container: el,
328
- style: this.config.mapboxStyle,
329
- center: [-77.036873, 38.907192],
330
- zoom: 10, bearing: 0, pitch: 65, interactive: true,
331
- });
332
- this.map.once('load', (res) => {
333
- resolve(res);
334
- });
335
- });
336
- }
337
- // Below method Load route with animation
338
- loadMapProperty(pinRouteGeojson, index, unit, route, bottom) {
339
- return new Promise((resolve, reject) => {
340
- let origin = pinRouteGeojson.features[0].geometry.coordinates[0];
341
- const linecolor = (unit === 'Ton') ? '#ff7272' : (unit === 'Load') ? '#a3c52e' : '#ae23d1';
342
- let destination = pinRouteGeojson.features[0].geometry.coordinates[pinRouteGeojson.features[0].geometry.coordinates.length - 1];
343
- this.extendBound(pinRouteGeojson.features[0].geometry.coordinates, true).then((res) => {
344
- const point = {
345
- 'type': 'FeatureCollection',
346
- 'features': [
347
- { 'type': 'Feature', 'properties': {}, 'geometry': { 'type': 'Point', 'coordinates': origin } }
348
- ]
349
- };
350
- const lineDistance = turf.length(pinRouteGeojson.features[0]);
351
- const arc = [];
352
- const steps = 10 * pinRouteGeojson.features[0].geometry.coordinates.length;
353
- for (let i = 0; i < lineDistance; i += lineDistance / steps) {
354
- const segment = turf.along(pinRouteGeojson.features[0], i);
355
- arc.push(segment.geometry.coordinates);
356
- }
357
- pinRouteGeojson.features[0].geometry.coordinates = arc;
358
- const pinRoute = pinRouteGeojson.features[0].geometry.coordinates;
359
- const marker = new mapboxgl.Marker(document.createElement('div'))
360
- .setLngLat(pinRoute[0]).addTo(this.map).togglePopup();
361
- if (this.map.getSource(`line${index}`)) {
362
- this.removeRouteAndMarker(index).then(() => { });
363
- }
364
- this.map.addSource(`line${index}`, { type: 'geojson', lineMetrics: true, data: pinRouteGeojson });
365
- this.map.addLayer({
366
- type: 'line',
367
- source: `line${index}`,
368
- id: `line${index}`,
369
- paint: {
370
- 'line-width': 2,
371
- 'line-gradient': [
372
- 'interpolate',
373
- ['linear'],
374
- ['line-progress'],
375
- 0, unit === 'Ton' ? '#d7f7e4' : unit === 'Load' ? '#c9d8f5' : '#f5dcc1',
376
- 1, unit === 'Ton' ? '#ff7272' : unit === 'Load' ? '#a3c52e' : '#ae23d1',
377
- ]
378
- },
379
- layout: { 'line-cap': 'round', 'line-join': 'round' }
380
- });
381
- const dataSetForMap = {
382
- counter: 0, pinRouteGeojson, steps,
383
- point, pointId: `point${index}`,
384
- marker, pinRoute, lineId: `line${index}`, index,
385
- origin, destination, lineDistance,
386
- linecolor, route, isViewRoute: true
387
- };
388
- this.createMarker(dataSetForMap);
389
- this.map.on('mouseenter', `line${index}`, (e) => {
390
- this.map.setPaintProperty(`line${index}`, 'line-width', 5);
391
- this.map.setPaintProperty(`line${index}`, 'line-opacity', 1);
392
- const datasetForPopup = {
393
- coordinate: [e.lngLat.lng, e.lngLat.lat],
394
- pickup: route.pickup_location ? route.pickup_location : '',
395
- drop: route.delivery_location ? route.delivery_location : '',
396
- routeType: route.project ? 'Project' : 'Route',
397
- title: route.project ? route.project : route.route_name ? route.route_name : '',
398
- material: route.material ? route.material : '',
399
- type: route.unit ? route.unit : ''
400
- };
401
- this.createPopup(datasetForPopup);
402
- });
403
- this.map.on('mouseleave', `line${index}`, (e) => {
404
- this.map.setPaintProperty(`line${index}`, 'line-width', 2);
405
- if (this.popup) {
406
- this.popup.remove();
407
- }
408
- });
409
- });
410
- this.map.once('idle', (res) => {
411
- resolve(true);
412
- });
413
- });
414
- }
415
- // Below method Load route without animation
416
- drawLine(cordinates, index, route, enablefitbound, routeType) {
417
- let linecolor;
418
- let origin = cordinates[0];
419
- let destination = cordinates[cordinates.length - 1];
420
- if (origin[0] && origin[1] && destination && destination[0] && destination[1]) {
421
- linecolor = this.provideLineColor(route['unit'], routeType);
422
- if (enablefitbound) {
423
- const padding = {
424
- top: this.padding.top + this.customTopForCustomer, bottom: this.padding.bottom + (this.windowActualHeightWidth.availHeight - (window.innerHeight - 65)),
425
- left: this.padding.left, right: this.padding.right
426
- };
427
- this.map.fitBounds([origin, destination], { padding, pitch: 65 }, { fitboundCompleteJob: true });
428
- }
429
- if (this.map.getSource(`route-source-for-job-code${index}`)) {
430
- this.removeRouteAndMarker(index).then(() => { });
431
- }
432
- this.map.addSource(`route-source-for-job-code${index}`, {
433
- 'type': 'geojson',
434
- 'data': { 'type': 'Feature', 'properties': {}, 'geometry': { 'type': 'LineString', 'coordinates': cordinates } }
435
- });
436
- this.map.addLayer({
437
- 'id': `route-for-job-code${index}`, 'type': 'line', 'source': `route-source-for-job-code${index}`,
438
- paint: { 'line-color': linecolor, 'line-width': 2 },
439
- layout: { 'line-cap': 'round', 'line-join': 'round' }
440
- });
441
- const dataSetForMap = {
442
- origin, destination, index, linecolor, route
443
- };
444
- this.createMarker(dataSetForMap);
445
- this.map.on('mouseenter', `route-for-job-code${index}`, (e) => {
446
- if (this.popup) {
447
- this.popup.remove();
448
- }
449
- this.map.setPaintProperty(`route-for-job-code${index}`, 'line-width', 5);
450
- this.map.setPaintProperty(`route-for-job-code${index}`, 'line-opacity', 1);
451
- const datasetForPopup = {
452
- coordinate: [e.lngLat.lng, e.lngLat.lat],
453
- pickup: route.pickup_location ? route.pickup_location : '',
454
- drop: route.delivery_location ? route.delivery_location : '',
455
- jobCode: route.project ? route.order_number : null,
456
- customer: route.project ? route.customer_name : null,
457
- routeType: route.project ? 'Project' : 'Route',
458
- title: route.project ? route.project : route.route_name ? route.route_name : '',
459
- material: route.material ? route.material : '',
460
- type: route.unit ? route.unit : ''
461
- };
462
- this.createPopup(datasetForPopup);
463
- });
464
- this.map.on('mouseleave', `route-for-job-code${index}`, (e) => {
465
- this.map.setPaintProperty(`route-for-job-code${index}`, 'line-width', 2);
466
- if (this.popup) {
467
- this.popup.remove();
468
- }
469
- });
470
- }
471
- }
472
- provideLineColor(unitType, type) {
473
- let checkType = (type && !['jobrouteList', 'addroute'].includes(type)) ? true : false;
474
- let color;
475
- switch (unitType) {
476
- case "Ton":
477
- color = checkType ? '#39c471' : '#ff7272';
478
- break;
479
- case "Load":
480
- color = checkType ? '#326ad3' : '#a3c52e';
481
- break;
482
- case "Hourly":
483
- color = checkType ? '#ffad56' : '#ae23d1';
484
- break;
485
- }
486
- return color;
487
- }
488
- showRoutePopup(arcDetails, event, isViewRoute) {
489
- if (this.popup) {
490
- this.popup.remove();
491
- this.map.setPaintProperty(`${isViewRoute ? 'line' : 'route-for-job-code'}${arcDetails.layer.props.data.index}`, 'line-width', 2);
492
- }
493
- if (arcDetails.color && this.map.getLayoutProperty(arcDetails.layer.id, 'visibility') !== 'none') {
494
- this.map.setPaintProperty(`${isViewRoute ? 'line' : 'route-for-job-code'}${arcDetails.layer.props.data.index}`, 'line-width', 5);
495
- this.map.setPaintProperty(`${isViewRoute ? 'line' : 'route-for-job-code'}${arcDetails.layer.props.data.index}`, 'line-opacity', 1);
496
- const datasetForPopup = {
497
- coordinate: arcDetails.coordinate,
498
- pickup: arcDetails.layer.props.data.route.pickup_location ? arcDetails.layer.props.data.route.pickup_location : '',
499
- drop: arcDetails.layer.props.data.route.delivery_location ? arcDetails.layer.props.data.route.delivery_location : '',
500
- jobCode: arcDetails.layer.props.data.route.project ? arcDetails.layer.props.data.route.order_number : '',
501
- customer: arcDetails.layer.props.data.route.project ? arcDetails.layer.props.data.route.customer_name : '',
502
- routeType: arcDetails.layer.props.data.route.project ? 'Project' : 'Route',
503
- 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 : '',
504
- material: arcDetails.layer.props.data.route.material ? arcDetails.layer.props.data.route.material : '',
505
- type: arcDetails.layer.props.data.route.unit ? arcDetails.layer.props.data.route.unit : ''
506
- };
507
- this.createPopup(datasetForPopup);
508
- }
509
- }
510
- createPopup(datasetForPopup) {
511
- this.popup = new mapboxgl.Popup({
512
- closeButton: false,
513
- closeOnClick: false,
514
- closeOnMove: true,
515
- anchor: 'bottom-left'
516
- });
517
- this.popup.setLngLat(datasetForPopup.coordinate)
518
- .setHTML(`
519
- <div class="destination">
520
- <div class="duration">
521
- <p class="pickprt"><b>Pickup Location:</b> ${datasetForPopup.pickup}</p>
522
- <p class="dropprt"><b>Drop Location:</b> ${datasetForPopup.drop}</p>
523
- </div>
524
- ${datasetForPopup.jobCode ? '<span><b>Job Code:</b> ' + datasetForPopup.jobCode + '</span>' : ''}
525
- ${datasetForPopup.customer ? '<span><b>Customer:</b> ' + datasetForPopup.customer + '</span>' : ''}
526
- <span><b>${datasetForPopup.routeType} Name:</b> ${datasetForPopup.title}</span>
527
- <span><b>Material:</b> ${datasetForPopup.material}</span>
528
- <span><b>Type:</b> ${datasetForPopup.type}</span>
529
- </div>
530
- `)
531
- .addTo(this.map);
532
- }
533
- hexToRGB(hex) {
534
- return hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (m, r, g, b) => '#' + r + r + g + g + b + b)
535
- .substring(1).match(/.{2}/g)
536
- .map(x => parseInt(x, 16));
537
- }
538
- createMarker(routeDetails) {
539
- if (routeDetails.origin[0] && routeDetails.origin[1] && routeDetails.destination[0] && routeDetails.destination[1]) {
540
- const popup = new mapboxgl.Popup({ closeButton: false }).setHTML('<b>Pickup: </b>' + routeDetails.route?.pickup_location);
541
- const popupForDestination = new mapboxgl.Popup({ closeButton: false })
542
- .setHTML('<b>Delivery: </b>' + routeDetails.route?.delivery_location);
543
- const el = document.createElement('div');
544
- el.className = 'marker';
545
- el.innerHTML = `<span class='markerPointer' style='background:${routeDetails.linecolor}'><b>P</b><span class='markerSpan' style='border-top: 10px solid ${routeDetails.linecolor}'></span></span>`;
546
- const originMarker = new mapboxgl.Marker(el)
547
- .setPopup(popup).setLngLat(routeDetails.origin).addTo(this.map);
548
- originMarker.getElement().addEventListener('mouseenter', () => originMarker.togglePopup());
549
- originMarker.getElement().addEventListener('mouseleave', () => originMarker.togglePopup());
550
- const elementForDestination = document.createElement('div');
551
- elementForDestination.className = 'marker';
552
- elementForDestination.innerHTML = `<span class='markerPointer' style='background:${routeDetails.linecolor}'><b>D</b><span class='markerSpan' style='border-top: 10px solid ${routeDetails.linecolor}'></span></span>`;
553
- const destinationMarker = new mapboxgl.Marker(elementForDestination).setPopup(popupForDestination).setLngLat(routeDetails.destination).addTo(this.map);
554
- destinationMarker.getElement().addEventListener('mouseenter', () => destinationMarker.togglePopup());
555
- destinationMarker.getElement().addEventListener('mouseleave', () => destinationMarker.togglePopup());
556
- this.markerOriginList[routeDetails.index] = originMarker;
557
- this.markerDestinationList[routeDetails.index] = destinationMarker;
558
- const colorArray = this.hexToRGB(routeDetails.linecolor);
559
- const arcLayer = new MapboxLayer({
560
- id: 'arc-layer' + routeDetails.index,
561
- type: ArcLayer,
562
- pickable: true,
563
- data: { route: routeDetails.route, index: routeDetails.index },
564
- getWidth: 1,
565
- getSourcePosition: routeDetails.origin,
566
- getTargetPosition: routeDetails.destination,
567
- getTargetColor: [255, 255, 255],
568
- getSourceColor: [colorArray[0], colorArray[1], colorArray[2]],
569
- onHover: (info, event) => this.showRoutePopup(info, event, routeDetails.isViewRoute),
570
- });
571
- this.map.addLayer(arcLayer);
572
- }
573
- }
574
- async removeRouteAndMarker(index) {
575
- if (this.map) {
576
- this.map.getLayer(`arc-layer${index}`) ? this.map.removeLayer(`arc-layer${index}`) : '';
577
- this.map.getLayer(`line${index}`) ? this.map.removeLayer(`line${index}`) : '';
578
- this.map.getLayer(`custom_layer${index}`) ? this.map.removeLayer(`custom_layer${index}`) : '';
579
- this.map.getSource(`line${index}`) ? this.map.removeSource(`line${index}`) : '';
580
- this.map.getLayer(`route-for-job-code${index}`) ? this.map.removeLayer(`route-for-job-code${index}`) : '';
581
- this.map.getSource(`route-source-for-job-code${index}`) ? this.map.removeSource(`route-source-for-job-code${index}`) : '';
582
- this.findMarkerBound(index);
583
- this.markerOriginList[index] ? this.markerOriginList[index].remove() : '';
584
- this.markerDestinationList[index] ? this.markerDestinationList[index].remove() : '';
585
- await true;
586
- }
587
- }
588
- findMarkerBound(index) {
589
- 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)));
590
- if (indexOfCordinates >= 0) {
591
- this.originDestinationCordinates.splice(indexOfCordinates, 1);
592
- }
593
- }
594
- async filterRoute(ID, visibility, showAllFitbound) {
595
- if (ID) {
596
- if (this.map.getLayer(`route-for-job-code${ID}`)) {
597
- this.map.setLayoutProperty(`route-for-job-code${ID}`, 'visibility', visibility);
598
- const originM = this.markerOriginList[ID].getElement();
599
- originM.style.display = ((visibility === 'visible') ? 'block' : visibility);
600
- const destinationM = this.markerDestinationList[ID].getElement();
601
- destinationM.style.display = ((visibility === 'visible') ? 'block' : visibility);
602
- if (visibility === 'none' && showAllFitbound) {
603
- this.findMarkerBound(ID);
604
- this.extendReBound();
605
- }
606
- }
607
- if (this.map.getLayer(`arc-layer${ID}`)) {
608
- this.map.setLayoutProperty(`arc-layer${ID}`, 'visibility', visibility);
609
- }
610
- }
611
- await true;
612
- }
613
- extendBound(route, showAllFitbound) {
614
- return new Promise((resolve, reject) => {
615
- if (route) {
616
- if (typeof route === 'string') {
617
- let path = route.split(';');
618
- path = path.map((ele) => { return ele = this.formateLatLong(ele); });
619
- path.forEach((ele, index) => { if (ele.length === 1)
620
- path.splice(index, 1); });
621
- route = path;
622
- }
623
- if (route[0][0] && route[0][1] && route[route.length - 1][0] && route[route.length - 1][1]) {
624
- this.originDestinationCordinates.push(route);
625
- route.map((item) => {
626
- this.bounds.extend(item);
627
- });
628
- }
629
- }
630
- if (showAllFitbound) {
631
- 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 };
632
- setTimeout(() => {
633
- if (showAllFitbound && (Object.keys(this.bounds).length > 0))
634
- this.map.fitBounds(this.bounds, { padding, pitch: 65 }, { fitboundComplete: true });
635
- }, 100);
636
- this.map.once('moveend', (event) => { if (event.fitboundComplete) {
637
- resolve(true);
638
- } });
639
- }
640
- });
641
- }
642
- extendReBound(bottom) {
643
- return new Promise((resolve, reject) => {
644
- this.bounds = new mapboxgl.LngLatBounds();
645
- if (this.originDestinationCordinates.length >= 0) {
646
- this.originDestinationCordinates.map((item, index) => {
647
- item.map((route) => {
648
- this.bounds.extend(route);
649
- });
650
- if (index === (this.originDestinationCordinates.length - 1)) {
651
- 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 };
652
- setTimeout(() => {
653
- if (this.originDestinationCordinates.length > 0)
654
- this.map.fitBounds(this.bounds, { padding, pitch: 65 });
655
- }, 500);
656
- resolve(true);
657
- }
658
- });
659
- }
660
- else {
661
- resolve(true);
662
- }
663
- });
664
- }
665
- plotRoute(route, i, type, enablefitbound, showAllFitbound) {
666
- return new Promise((resolve, reject) => {
667
- let param = {};
668
- if (['jobcode'].includes(type)) {
669
- param['job'] = route['job_id'];
670
- this.utils.postDataWithRestUrl('schedule/job/path', param).subscribe((res) => {
671
- if (res['data']['route']) {
672
- let path = res['data']['route'].split(';');
673
- path = path.map((ele) => { return ele = this.formateLatLong(ele); });
674
- path.forEach((ele, index) => { if (ele.length === 1)
675
- path.splice(index, 1); });
676
- route['path'] = path;
677
- this.extendBound(route['path'], showAllFitbound);
678
- if (route['path'] && route['path'].length > 0)
679
- this.drawLine(route['path'], i, route, enablefitbound, type);
680
- route['index'] = i;
681
- }
682
- else {
683
- this.extendBound(null, showAllFitbound);
684
- }
685
- resolve(true);
686
- }, (err) => { if (err) {
687
- reject(false);
688
- } });
689
- }
690
- else if (['jobrouteList', 'addroute'].includes(type)) {
691
- if (route['path'] && route['path'].length > 0) {
692
- let path = route['path'].split(';');
693
- path = path.map((ele) => { return ele = this.formateLatLong(ele); });
694
- path.forEach((ele, index) => { if (ele.length === 1)
695
- path.splice(index, 1); });
696
- this.extendBound(path, showAllFitbound);
697
- this.drawLine(path, i, route, enablefitbound, type);
698
- }
699
- ;
700
- }
701
- });
702
- }
703
- clearBound() { this.bounds = new mapboxgl.LngLatBounds(); this.originDestinationCordinates = []; this.clearPadding(); }
704
- formateLatLong(latlong) { return latlong ? latlong.split(',').map(x => +x).reverse() : null; }
705
- clearBoundWithCordinates() {
706
- this.bounds = new mapboxgl.LngLatBounds();
707
- this.originDestinationCordinates = [];
708
- }
709
- onResize(event) {
710
- if (!this.bounds.isEmpty()) {
711
- this.windowActualHeightWidth.availHeight = (window.innerHeight > window.screen.availHeight) ? window.innerHeight : window.screen.availHeight;
712
- setTimeout(() => {
713
- 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 });
714
- }, 500);
715
- }
716
- }
717
- setWindowHeight(screen) {
718
- this.windowActualHeightWidth.availHeight = screen;
719
- }
720
- setPadding(padding) { this.padding = padding; }
721
- clearPadding() { this.padding = null; }
722
- removeJobFromMap(data) {
723
- data.map((ele, index) => {
724
- const id = (ele['job_id'] ? ele['job_id'] : ele['route_id']);
725
- this.removeRouteAndMarker(id);
726
- if (index === (data.length - 1)) {
727
- this.extendReBound();
728
- }
729
- });
730
- }
731
- }
732
- 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 });
733
- CoolmapService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CoolmapService, providedIn: 'root' });
734
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CoolmapService, decorators: [{
735
- type: Injectable,
736
- args: [{ providedIn: 'root' }]
737
- }], ctorParameters: function () { return [{ type: UtilsService }, { type: i2$1.EventManager }, { type: CoolmapConfigModel, decorators: [{
738
- type: Inject,
739
- args: ['memberData']
332
+ class CoolmapService {
333
+ constructor(utils, eventManager, config) {
334
+ this.utils = utils;
335
+ this.eventManager = eventManager;
336
+ this.config = config;
337
+ this.markerOriginList = [];
338
+ this.markerDestinationList = [];
339
+ this.initiatecoolmap = new BehaviorSubject(true);
340
+ this.reintiatecoolmap = this.initiatecoolmap.asObservable();
341
+ this.bounds = new mapboxgl.LngLatBounds();
342
+ this.originDestinationCordinates = [];
343
+ this.customTopForCustomer = this.config.repository === 'customer' ? 65 : 0;
344
+ this.eventManager.addGlobalEventListener('window', 'resize', this.onResize.bind(this));
345
+ this.windowActualHeightWidth = { availHeight: 0 };
346
+ }
347
+ initiateMapForAddRoute(el) {
348
+ return new Promise((resolve, reject) => {
349
+ if (this.map)
350
+ this.map.remove();
351
+ this.map = new mapboxgl.Map({
352
+ accessToken: this.config.mapboxAccessToken,
353
+ container: el,
354
+ style: this.config.mapboxStyle,
355
+ center: [-77.036873, 38.907192],
356
+ zoom: 10, bearing: 0, pitch: 65, interactive: true,
357
+ });
358
+ this.map.once('load', (res) => {
359
+ resolve(res);
360
+ });
361
+ });
362
+ }
363
+ // Below method Load route with animation
364
+ loadMapProperty(pinRouteGeojson, index, unit, route, bottom) {
365
+ return new Promise((resolve, reject) => {
366
+ let origin = pinRouteGeojson.features[0].geometry.coordinates[0];
367
+ const linecolor = (unit === 'Ton') ? '#ff7272' : (unit === 'Load') ? '#a3c52e' : '#ae23d1';
368
+ let destination = pinRouteGeojson.features[0].geometry.coordinates[pinRouteGeojson.features[0].geometry.coordinates.length - 1];
369
+ this.extendBound(pinRouteGeojson.features[0].geometry.coordinates, true).then((res) => {
370
+ const point = {
371
+ 'type': 'FeatureCollection',
372
+ 'features': [
373
+ { 'type': 'Feature', 'properties': {}, 'geometry': { 'type': 'Point', 'coordinates': origin } }
374
+ ]
375
+ };
376
+ const lineDistance = turf.length(pinRouteGeojson.features[0]);
377
+ const arc = [];
378
+ const steps = 10 * pinRouteGeojson.features[0].geometry.coordinates.length;
379
+ for (let i = 0; i < lineDistance; i += lineDistance / steps) {
380
+ const segment = turf.along(pinRouteGeojson.features[0], i);
381
+ arc.push(segment.geometry.coordinates);
382
+ }
383
+ pinRouteGeojson.features[0].geometry.coordinates = arc;
384
+ const pinRoute = pinRouteGeojson.features[0].geometry.coordinates;
385
+ const marker = new mapboxgl.Marker(document.createElement('div'))
386
+ .setLngLat(pinRoute[0]).addTo(this.map).togglePopup();
387
+ if (this.map.getSource(`line${index}`)) {
388
+ this.removeRouteAndMarker(index).then(() => { });
389
+ }
390
+ this.map.addSource(`line${index}`, { type: 'geojson', lineMetrics: true, data: pinRouteGeojson });
391
+ this.map.addLayer({
392
+ type: 'line',
393
+ source: `line${index}`,
394
+ id: `line${index}`,
395
+ paint: {
396
+ 'line-width': 2,
397
+ 'line-gradient': [
398
+ 'interpolate',
399
+ ['linear'],
400
+ ['line-progress'],
401
+ 0, unit === 'Ton' ? '#d7f7e4' : unit === 'Load' ? '#c9d8f5' : '#f5dcc1',
402
+ 1, unit === 'Ton' ? '#ff7272' : unit === 'Load' ? '#a3c52e' : '#ae23d1',
403
+ ]
404
+ },
405
+ layout: { 'line-cap': 'round', 'line-join': 'round' }
406
+ });
407
+ const dataSetForMap = {
408
+ counter: 0, pinRouteGeojson, steps,
409
+ point, pointId: `point${index}`,
410
+ marker, pinRoute, lineId: `line${index}`, index,
411
+ origin, destination, lineDistance,
412
+ linecolor, route, isViewRoute: true
413
+ };
414
+ this.createMarker(dataSetForMap);
415
+ this.map.on('mouseenter', `line${index}`, (e) => {
416
+ this.map.setPaintProperty(`line${index}`, 'line-width', 5);
417
+ this.map.setPaintProperty(`line${index}`, 'line-opacity', 1);
418
+ const datasetForPopup = {
419
+ coordinate: [e.lngLat.lng, e.lngLat.lat],
420
+ pickup: route.pickup_location ? route.pickup_location : '',
421
+ drop: route.delivery_location ? route.delivery_location : '',
422
+ routeType: route.project ? 'Project' : 'Route',
423
+ title: route.project ? route.project : route.route_name ? route.route_name : '',
424
+ material: route.material ? route.material : '',
425
+ type: route.unit ? route.unit : ''
426
+ };
427
+ this.createPopup(datasetForPopup);
428
+ });
429
+ this.map.on('mouseleave', `line${index}`, (e) => {
430
+ this.map.setPaintProperty(`line${index}`, 'line-width', 2);
431
+ if (this.popup) {
432
+ this.popup.remove();
433
+ }
434
+ });
435
+ });
436
+ this.map.once('idle', (res) => {
437
+ resolve(true);
438
+ });
439
+ });
440
+ }
441
+ // Below method Load route without animation
442
+ drawLine(cordinates, index, route, enablefitbound, routeType) {
443
+ let linecolor;
444
+ let origin = cordinates[0];
445
+ let destination = cordinates[cordinates.length - 1];
446
+ if (origin[0] && origin[1] && destination && destination[0] && destination[1]) {
447
+ linecolor = this.provideLineColor(route['unit'], routeType);
448
+ if (enablefitbound) {
449
+ const padding = {
450
+ top: this.padding.top + this.customTopForCustomer, bottom: this.padding.bottom + (this.windowActualHeightWidth.availHeight - (window.innerHeight - 65)),
451
+ left: this.padding.left, right: this.padding.right
452
+ };
453
+ this.map.fitBounds([origin, destination], { padding, pitch: 65 }, { fitboundCompleteJob: true });
454
+ }
455
+ if (this.map.getSource(`route-source-for-job-code${index}`)) {
456
+ this.removeRouteAndMarker(index).then(() => { });
457
+ }
458
+ this.map.addSource(`route-source-for-job-code${index}`, {
459
+ 'type': 'geojson',
460
+ 'data': { 'type': 'Feature', 'properties': {}, 'geometry': { 'type': 'LineString', 'coordinates': cordinates } }
461
+ });
462
+ this.map.addLayer({
463
+ 'id': `route-for-job-code${index}`, 'type': 'line', 'source': `route-source-for-job-code${index}`,
464
+ paint: { 'line-color': linecolor, 'line-width': 2 },
465
+ layout: { 'line-cap': 'round', 'line-join': 'round' }
466
+ });
467
+ const dataSetForMap = {
468
+ origin, destination, index, linecolor, route
469
+ };
470
+ this.createMarker(dataSetForMap);
471
+ this.map.on('mouseenter', `route-for-job-code${index}`, (e) => {
472
+ if (this.popup) {
473
+ this.popup.remove();
474
+ }
475
+ this.map.setPaintProperty(`route-for-job-code${index}`, 'line-width', 5);
476
+ this.map.setPaintProperty(`route-for-job-code${index}`, 'line-opacity', 1);
477
+ const datasetForPopup = {
478
+ coordinate: [e.lngLat.lng, e.lngLat.lat],
479
+ pickup: route.pickup_location ? route.pickup_location : '',
480
+ drop: route.delivery_location ? route.delivery_location : '',
481
+ jobCode: route.project ? route.order_number : null,
482
+ customer: route.project ? route.customer_name : null,
483
+ routeType: route.project ? 'Project' : 'Route',
484
+ title: route.project ? route.project : route.route_name ? route.route_name : '',
485
+ material: route.material ? route.material : '',
486
+ type: route.unit ? route.unit : ''
487
+ };
488
+ this.createPopup(datasetForPopup);
489
+ });
490
+ this.map.on('mouseleave', `route-for-job-code${index}`, (e) => {
491
+ this.map.setPaintProperty(`route-for-job-code${index}`, 'line-width', 2);
492
+ if (this.popup) {
493
+ this.popup.remove();
494
+ }
495
+ });
496
+ }
497
+ }
498
+ provideLineColor(unitType, type) {
499
+ let checkType = (type && !['jobrouteList', 'addroute'].includes(type)) ? true : false;
500
+ let color;
501
+ switch (unitType) {
502
+ case "Ton":
503
+ color = checkType ? '#39c471' : '#ff7272';
504
+ break;
505
+ case "Load":
506
+ color = checkType ? '#326ad3' : '#a3c52e';
507
+ break;
508
+ case "Hourly":
509
+ color = checkType ? '#ffad56' : '#ae23d1';
510
+ break;
511
+ }
512
+ return color;
513
+ }
514
+ showRoutePopup(arcDetails, event, isViewRoute) {
515
+ if (this.popup) {
516
+ this.popup.remove();
517
+ this.map.setPaintProperty(`${isViewRoute ? 'line' : 'route-for-job-code'}${arcDetails.layer.props.data.index}`, 'line-width', 2);
518
+ }
519
+ if (arcDetails.color && this.map.getLayoutProperty(arcDetails.layer.id, 'visibility') !== 'none') {
520
+ this.map.setPaintProperty(`${isViewRoute ? 'line' : 'route-for-job-code'}${arcDetails.layer.props.data.index}`, 'line-width', 5);
521
+ this.map.setPaintProperty(`${isViewRoute ? 'line' : 'route-for-job-code'}${arcDetails.layer.props.data.index}`, 'line-opacity', 1);
522
+ const datasetForPopup = {
523
+ coordinate: arcDetails.coordinate,
524
+ pickup: arcDetails.layer.props.data.route.pickup_location ? arcDetails.layer.props.data.route.pickup_location : '',
525
+ drop: arcDetails.layer.props.data.route.delivery_location ? arcDetails.layer.props.data.route.delivery_location : '',
526
+ jobCode: arcDetails.layer.props.data.route.project ? arcDetails.layer.props.data.route.order_number : '',
527
+ customer: arcDetails.layer.props.data.route.project ? arcDetails.layer.props.data.route.customer_name : '',
528
+ routeType: arcDetails.layer.props.data.route.project ? 'Project' : 'Route',
529
+ 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 : '',
530
+ material: arcDetails.layer.props.data.route.material ? arcDetails.layer.props.data.route.material : '',
531
+ type: arcDetails.layer.props.data.route.unit ? arcDetails.layer.props.data.route.unit : ''
532
+ };
533
+ this.createPopup(datasetForPopup);
534
+ }
535
+ }
536
+ createPopup(datasetForPopup) {
537
+ this.popup = new mapboxgl.Popup({
538
+ closeButton: false,
539
+ closeOnClick: false,
540
+ closeOnMove: true,
541
+ anchor: 'bottom-left'
542
+ });
543
+ this.popup.setLngLat(datasetForPopup.coordinate)
544
+ .setHTML(`
545
+ <div class="destination">
546
+ <div class="duration">
547
+ <p class="pickprt"><b>Pickup Location:</b> ${datasetForPopup.pickup}</p>
548
+ <p class="dropprt"><b>Drop Location:</b> ${datasetForPopup.drop}</p>
549
+ </div>
550
+ ${datasetForPopup.jobCode ? '<span><b>Job Code:</b> ' + datasetForPopup.jobCode + '</span>' : ''}
551
+ ${datasetForPopup.customer ? '<span><b>Customer:</b> ' + datasetForPopup.customer + '</span>' : ''}
552
+ <span><b>${datasetForPopup.routeType} Name:</b> ${datasetForPopup.title}</span>
553
+ <span><b>Material:</b> ${datasetForPopup.material}</span>
554
+ <span><b>Type:</b> ${datasetForPopup.type}</span>
555
+ </div>
556
+ `)
557
+ .addTo(this.map);
558
+ }
559
+ hexToRGB(hex) {
560
+ return hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (m, r, g, b) => '#' + r + r + g + g + b + b)
561
+ .substring(1).match(/.{2}/g)
562
+ .map(x => parseInt(x, 16));
563
+ }
564
+ createMarker(routeDetails) {
565
+ if (routeDetails.origin[0] && routeDetails.origin[1] && routeDetails.destination[0] && routeDetails.destination[1]) {
566
+ const popup = new mapboxgl.Popup({ closeButton: false }).setHTML('<b>Pickup: </b>' + routeDetails.route?.pickup_location);
567
+ const popupForDestination = new mapboxgl.Popup({ closeButton: false })
568
+ .setHTML('<b>Delivery: </b>' + routeDetails.route?.delivery_location);
569
+ const el = document.createElement('div');
570
+ el.className = 'marker';
571
+ el.innerHTML = `<span class='markerPointer' style='background:${routeDetails.linecolor}'><b>P</b><span class='markerSpan' style='border-top: 10px solid ${routeDetails.linecolor}'></span></span>`;
572
+ const originMarker = new mapboxgl.Marker(el)
573
+ .setPopup(popup).setLngLat(routeDetails.origin).addTo(this.map);
574
+ originMarker.getElement().addEventListener('mouseenter', () => originMarker.togglePopup());
575
+ originMarker.getElement().addEventListener('mouseleave', () => originMarker.togglePopup());
576
+ const elementForDestination = document.createElement('div');
577
+ elementForDestination.className = 'marker';
578
+ elementForDestination.innerHTML = `<span class='markerPointer' style='background:${routeDetails.linecolor}'><b>D</b><span class='markerSpan' style='border-top: 10px solid ${routeDetails.linecolor}'></span></span>`;
579
+ const destinationMarker = new mapboxgl.Marker(elementForDestination).setPopup(popupForDestination).setLngLat(routeDetails.destination).addTo(this.map);
580
+ destinationMarker.getElement().addEventListener('mouseenter', () => destinationMarker.togglePopup());
581
+ destinationMarker.getElement().addEventListener('mouseleave', () => destinationMarker.togglePopup());
582
+ this.markerOriginList[routeDetails.index] = originMarker;
583
+ this.markerDestinationList[routeDetails.index] = destinationMarker;
584
+ const colorArray = this.hexToRGB(routeDetails.linecolor);
585
+ const arcLayer = new MapboxLayer({
586
+ id: 'arc-layer' + routeDetails.index,
587
+ type: ArcLayer,
588
+ pickable: true,
589
+ data: { route: routeDetails.route, index: routeDetails.index },
590
+ getWidth: 1,
591
+ getSourcePosition: routeDetails.origin,
592
+ getTargetPosition: routeDetails.destination,
593
+ getTargetColor: [255, 255, 255],
594
+ getSourceColor: [colorArray[0], colorArray[1], colorArray[2]],
595
+ onHover: (info, event) => this.showRoutePopup(info, event, routeDetails.isViewRoute),
596
+ });
597
+ this.map.addLayer(arcLayer);
598
+ }
599
+ }
600
+ async removeRouteAndMarker(index) {
601
+ if (this.map) {
602
+ this.map.getLayer(`arc-layer${index}`) ? this.map.removeLayer(`arc-layer${index}`) : '';
603
+ this.map.getLayer(`line${index}`) ? this.map.removeLayer(`line${index}`) : '';
604
+ this.map.getLayer(`custom_layer${index}`) ? this.map.removeLayer(`custom_layer${index}`) : '';
605
+ this.map.getSource(`line${index}`) ? this.map.removeSource(`line${index}`) : '';
606
+ this.map.getLayer(`route-for-job-code${index}`) ? this.map.removeLayer(`route-for-job-code${index}`) : '';
607
+ this.map.getSource(`route-source-for-job-code${index}`) ? this.map.removeSource(`route-source-for-job-code${index}`) : '';
608
+ this.findMarkerBound(index);
609
+ this.markerOriginList[index] ? this.markerOriginList[index].remove() : '';
610
+ this.markerDestinationList[index] ? this.markerDestinationList[index].remove() : '';
611
+ await true;
612
+ }
613
+ }
614
+ findMarkerBound(index) {
615
+ 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)));
616
+ if (indexOfCordinates >= 0) {
617
+ this.originDestinationCordinates.splice(indexOfCordinates, 1);
618
+ }
619
+ }
620
+ async filterRoute(ID, visibility, showAllFitbound) {
621
+ if (ID) {
622
+ if (this.map.getLayer(`route-for-job-code${ID}`)) {
623
+ this.map.setLayoutProperty(`route-for-job-code${ID}`, 'visibility', visibility);
624
+ const originM = this.markerOriginList[ID].getElement();
625
+ originM.style.display = ((visibility === 'visible') ? 'block' : visibility);
626
+ const destinationM = this.markerDestinationList[ID].getElement();
627
+ destinationM.style.display = ((visibility === 'visible') ? 'block' : visibility);
628
+ if (visibility === 'none' && showAllFitbound) {
629
+ this.findMarkerBound(ID);
630
+ this.extendReBound();
631
+ }
632
+ }
633
+ if (this.map.getLayer(`arc-layer${ID}`)) {
634
+ this.map.setLayoutProperty(`arc-layer${ID}`, 'visibility', visibility);
635
+ }
636
+ }
637
+ await true;
638
+ }
639
+ extendBound(route, showAllFitbound) {
640
+ return new Promise((resolve, reject) => {
641
+ if (route) {
642
+ if (typeof route === 'string') {
643
+ let path = route.split(';');
644
+ path = path.map((ele) => { return ele = this.formateLatLong(ele); });
645
+ path.forEach((ele, index) => { if (ele.length === 1)
646
+ path.splice(index, 1); });
647
+ route = path;
648
+ }
649
+ if (route[0][0] && route[0][1] && route[route.length - 1][0] && route[route.length - 1][1]) {
650
+ this.originDestinationCordinates.push(route);
651
+ route.map((item) => {
652
+ this.bounds.extend(item);
653
+ });
654
+ }
655
+ }
656
+ if (showAllFitbound) {
657
+ 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 };
658
+ setTimeout(() => {
659
+ if (showAllFitbound && (Object.keys(this.bounds).length > 0))
660
+ this.map.fitBounds(this.bounds, { padding, pitch: 65 }, { fitboundComplete: true });
661
+ }, 100);
662
+ this.map.once('moveend', (event) => { if (event.fitboundComplete) {
663
+ resolve(true);
664
+ } });
665
+ }
666
+ });
667
+ }
668
+ extendReBound(bottom) {
669
+ return new Promise((resolve, reject) => {
670
+ this.bounds = new mapboxgl.LngLatBounds();
671
+ if (this.originDestinationCordinates.length >= 0) {
672
+ this.originDestinationCordinates.map((item, index) => {
673
+ item.map((route) => {
674
+ this.bounds.extend(route);
675
+ });
676
+ if (index === (this.originDestinationCordinates.length - 1)) {
677
+ 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 };
678
+ setTimeout(() => {
679
+ if (this.originDestinationCordinates.length > 0)
680
+ this.map.fitBounds(this.bounds, { padding, pitch: 65 });
681
+ }, 500);
682
+ resolve(true);
683
+ }
684
+ });
685
+ }
686
+ else {
687
+ resolve(true);
688
+ }
689
+ });
690
+ }
691
+ plotRoute(route, i, type, enablefitbound, showAllFitbound) {
692
+ return new Promise((resolve, reject) => {
693
+ let param = {};
694
+ if (['jobcode'].includes(type)) {
695
+ param['job'] = route['job_id'];
696
+ this.utils.postDataWithRestUrl('schedule/job/path', param).subscribe((res) => {
697
+ if (res['data']['route']) {
698
+ let path = res['data']['route'].split(';');
699
+ path = path.map((ele) => { return ele = this.formateLatLong(ele); });
700
+ path.forEach((ele, index) => { if (ele.length === 1)
701
+ path.splice(index, 1); });
702
+ route['path'] = path;
703
+ this.extendBound(route['path'], showAllFitbound);
704
+ if (route['path'] && route['path'].length > 0)
705
+ this.drawLine(route['path'], i, route, enablefitbound, type);
706
+ route['index'] = i;
707
+ }
708
+ else {
709
+ this.extendBound(null, showAllFitbound);
710
+ }
711
+ resolve(true);
712
+ }, (err) => { if (err) {
713
+ reject(false);
714
+ } });
715
+ }
716
+ else if (['jobrouteList', 'addroute'].includes(type)) {
717
+ if (route['path'] && route['path'].length > 0) {
718
+ let path = route['path'].split(';');
719
+ path = path.map((ele) => { return ele = this.formateLatLong(ele); });
720
+ path.forEach((ele, index) => { if (ele.length === 1)
721
+ path.splice(index, 1); });
722
+ this.extendBound(path, showAllFitbound);
723
+ this.drawLine(path, i, route, enablefitbound, type);
724
+ }
725
+ ;
726
+ }
727
+ });
728
+ }
729
+ clearBound() { this.bounds = new mapboxgl.LngLatBounds(); this.originDestinationCordinates = []; this.clearPadding(); }
730
+ formateLatLong(latlong) { return latlong ? latlong.split(',').map(x => +x).reverse() : null; }
731
+ clearBoundWithCordinates() {
732
+ this.bounds = new mapboxgl.LngLatBounds();
733
+ this.originDestinationCordinates = [];
734
+ }
735
+ onResize(event) {
736
+ if (!this.bounds.isEmpty()) {
737
+ this.windowActualHeightWidth.availHeight = (window.innerHeight > window.screen.availHeight) ? window.innerHeight : window.screen.availHeight;
738
+ setTimeout(() => {
739
+ 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 });
740
+ }, 500);
741
+ }
742
+ }
743
+ setWindowHeight(screen) {
744
+ this.windowActualHeightWidth.availHeight = screen;
745
+ }
746
+ setPadding(padding) { this.padding = padding; }
747
+ clearPadding() { this.padding = null; }
748
+ removeJobFromMap(data) {
749
+ data.map((ele, index) => {
750
+ const id = (ele['job_id'] ? ele['job_id'] : ele['route_id']);
751
+ this.removeRouteAndMarker(id);
752
+ if (index === (data.length - 1)) {
753
+ this.extendReBound();
754
+ }
755
+ });
756
+ }
757
+ }
758
+ 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 });
759
+ CoolmapService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CoolmapService, providedIn: 'root' });
760
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CoolmapService, decorators: [{
761
+ type: Injectable,
762
+ args: [{ providedIn: 'root' }]
763
+ }], ctorParameters: function () { return [{ type: UtilsService }, { type: i2$1.EventManager }, { type: CoolmapConfigModel, decorators: [{
764
+ type: Inject,
765
+ args: ['memberData']
740
766
  }] }]; } });
741
767
 
742
- /*
743
- * Public API Surface of coolmap-services
768
+ /*
769
+ * Public API Surface of @aggdirect/coolmap-services
744
770
  */
745
771
 
746
- /**
747
- * Generated bundle index. Do not edit.
772
+ /**
773
+ * Generated bundle index. Do not edit.
748
774
  */
749
775
 
750
776
  export { CoolmapConfigModel, CoolmapService, DriverSmsCardEnum, DriversmsCardKey, EstinationData, EstinationEnum, JobCodeOverviewData, JobCodeOverviewEnum, PopupData, Route, UtilsService };
751
- //# sourceMappingURL=coolmap-services.mjs.map
777
+ //# sourceMappingURL=aggdirect-coolmap-services.mjs.map