@aggdirect/coolmap-services 1.0.9 → 1.1.0

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