@aggdirect/coolmap-services 1.1.4 → 1.1.5

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