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