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