@aggdirect/coolmap-services 1.4.9 → 4.0.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 +43 -18
- package/fesm2022/coolmap-services.mjs +1339 -0
- package/fesm2022/coolmap-services.mjs.map +1 -0
- package/index.d.ts +212 -5
- package/package.json +19 -28
- package/esm2022/aggdirect-coolmap-services.mjs +0 -5
- package/esm2022/lib/service/coolmap.service.mjs +0 -637
- package/esm2022/lib/service/data-model.mjs +0 -92
- package/esm2022/lib/service/utils.service.mjs +0 -400
- package/esm2022/public-api.mjs +0 -7
- package/fesm2022/aggdirect-coolmap-services.mjs +0 -1134
- package/fesm2022/aggdirect-coolmap-services.mjs.map +0 -1
- package/lib/service/coolmap.service.d.ts +0 -47
- package/lib/service/data-model.d.ts +0 -94
- package/lib/service/utils.service.d.ts +0 -78
- package/public-api.d.ts +0 -3
|
@@ -1,1134 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, Inject } from '@angular/core';
|
|
3
|
-
import * as mapboxgl from 'mapbox-gl';
|
|
4
|
-
import * as turf from '@turf/turf';
|
|
5
|
-
import { BehaviorSubject } from 'rxjs';
|
|
6
|
-
import { MapboxLayer } from '@deck.gl/mapbox';
|
|
7
|
-
import { ArcLayer } from '@deck.gl/layers';
|
|
8
|
-
import * as i1 from '@angular/common/http';
|
|
9
|
-
import * as i2 from '@angular/material/snack-bar';
|
|
10
|
-
import * as i2$1 from '@angular/platform-browser';
|
|
11
|
-
|
|
12
|
-
class Route {
|
|
13
|
-
index = 0;
|
|
14
|
-
type;
|
|
15
|
-
// Job Code
|
|
16
|
-
customer_contact;
|
|
17
|
-
customer_name;
|
|
18
|
-
delivery_contact;
|
|
19
|
-
delivery_lat;
|
|
20
|
-
delivery_location;
|
|
21
|
-
delivery_lon;
|
|
22
|
-
driver_list;
|
|
23
|
-
material;
|
|
24
|
-
order_number;
|
|
25
|
-
pickup_lat;
|
|
26
|
-
pickup_location;
|
|
27
|
-
pickup_lon;
|
|
28
|
-
project;
|
|
29
|
-
total_count;
|
|
30
|
-
unit;
|
|
31
|
-
values;
|
|
32
|
-
job_id;
|
|
33
|
-
isSelected;
|
|
34
|
-
date;
|
|
35
|
-
// Add Route
|
|
36
|
-
created_at;
|
|
37
|
-
created_by_name;
|
|
38
|
-
customer_id;
|
|
39
|
-
delivery_lat_lng;
|
|
40
|
-
estimated_distance;
|
|
41
|
-
estimated_time;
|
|
42
|
-
materials_id;
|
|
43
|
-
path;
|
|
44
|
-
pickup_lat_lng;
|
|
45
|
-
route_id;
|
|
46
|
-
route_name;
|
|
47
|
-
unit_id;
|
|
48
|
-
note;
|
|
49
|
-
materialLabel;
|
|
50
|
-
isActive;
|
|
51
|
-
prevent;
|
|
52
|
-
is_system_pickup;
|
|
53
|
-
is_system_delivery;
|
|
54
|
-
}
|
|
55
|
-
const EstinationData = ['estimated_distance', 'estimated_time'];
|
|
56
|
-
var EstinationEnum;
|
|
57
|
-
(function (EstinationEnum) {
|
|
58
|
-
EstinationEnum["estimated_distance"] = "miles";
|
|
59
|
-
EstinationEnum["estimated_time"] = "time";
|
|
60
|
-
})(EstinationEnum || (EstinationEnum = {}));
|
|
61
|
-
const JobCodeOverviewData = ['order_number', 'customer_name', 'project', 'unit', 'material', 'customer_contact', 'delivery_contact', 'pickup_location', 'delivery_location'];
|
|
62
|
-
var JobCodeOverviewEnum;
|
|
63
|
-
(function (JobCodeOverviewEnum) {
|
|
64
|
-
JobCodeOverviewEnum["material"] = "Material";
|
|
65
|
-
JobCodeOverviewEnum["order_number"] = "Job Code";
|
|
66
|
-
JobCodeOverviewEnum["customer_name"] = "Customer";
|
|
67
|
-
JobCodeOverviewEnum["customer_contact"] = "Customer Contact";
|
|
68
|
-
JobCodeOverviewEnum["delivery_contact"] = "Delivery Contact";
|
|
69
|
-
JobCodeOverviewEnum["project"] = "Project Name";
|
|
70
|
-
JobCodeOverviewEnum["unit"] = "Job Type";
|
|
71
|
-
JobCodeOverviewEnum["pickup_location"] = "Pickup";
|
|
72
|
-
JobCodeOverviewEnum["delivery_location"] = "Delivery";
|
|
73
|
-
})(JobCodeOverviewEnum || (JobCodeOverviewEnum = {}));
|
|
74
|
-
const DriversmsCardKey = ['order_number', 'date', 'values', 'material', 'unit', 'pickup_location', 'delivery_location'];
|
|
75
|
-
var DriverSmsCardEnum;
|
|
76
|
-
(function (DriverSmsCardEnum) {
|
|
77
|
-
DriverSmsCardEnum["order_number"] = "Jobcode";
|
|
78
|
-
DriverSmsCardEnum["date"] = "Date";
|
|
79
|
-
DriverSmsCardEnum["values"] = "Total tasks";
|
|
80
|
-
DriverSmsCardEnum["material"] = "Material";
|
|
81
|
-
DriverSmsCardEnum["unit"] = "Unit";
|
|
82
|
-
DriverSmsCardEnum["pickup_location"] = "Pickup Address";
|
|
83
|
-
DriverSmsCardEnum["delivery_location"] = "Delivery Address";
|
|
84
|
-
})(DriverSmsCardEnum || (DriverSmsCardEnum = {}));
|
|
85
|
-
class PopupData {
|
|
86
|
-
coordinate;
|
|
87
|
-
pickup;
|
|
88
|
-
jobCode;
|
|
89
|
-
customer;
|
|
90
|
-
drop;
|
|
91
|
-
routeType;
|
|
92
|
-
title;
|
|
93
|
-
material;
|
|
94
|
-
type;
|
|
95
|
-
}
|
|
96
|
-
class CoolmapConfigModel {
|
|
97
|
-
analyticsRESTURL;
|
|
98
|
-
RESTURLPrefix;
|
|
99
|
-
repository;
|
|
100
|
-
mapboxStyle;
|
|
101
|
-
mapboxAccessToken;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
class UtilsService {
|
|
105
|
-
http;
|
|
106
|
-
snackBar;
|
|
107
|
-
config;
|
|
108
|
-
ngZone;
|
|
109
|
-
analyticsRESTURL = '';
|
|
110
|
-
RESTURLPrefix = '';
|
|
111
|
-
pickupOptions = [];
|
|
112
|
-
destOptions = [];
|
|
113
|
-
ownerOptions = [];
|
|
114
|
-
customerOptions = [];
|
|
115
|
-
unitOptions = [];
|
|
116
|
-
materialOptions = [];
|
|
117
|
-
jcodeOptions = [];
|
|
118
|
-
driverOption = [];
|
|
119
|
-
truckingCompanayOption = [];
|
|
120
|
-
routeNameOptions = [];
|
|
121
|
-
preventnavChange = new BehaviorSubject(false);
|
|
122
|
-
navChangeObserve = this.preventnavChange.asObservable();
|
|
123
|
-
clearViewRouteforJobCode = new BehaviorSubject(false);
|
|
124
|
-
clearViewRouteforJobCodeObserve = this.clearViewRouteforJobCode.asObservable();
|
|
125
|
-
preVentJobdetailclose = new BehaviorSubject(false);
|
|
126
|
-
getpreVentJobdetailclose = this.preVentJobdetailclose.asObservable();
|
|
127
|
-
routeDetailsUtility = new BehaviorSubject({});
|
|
128
|
-
getrouteDetailsUtility = this.routeDetailsUtility.asObservable();
|
|
129
|
-
removeMapEntity = new BehaviorSubject({});
|
|
130
|
-
removeMapEntityUtility = this.removeMapEntity.asObservable();
|
|
131
|
-
dict = new Map();
|
|
132
|
-
unitsList;
|
|
133
|
-
materialsList;
|
|
134
|
-
materialsListForCustomer;
|
|
135
|
-
customersList;
|
|
136
|
-
locationList;
|
|
137
|
-
pickUpAutocomplete;
|
|
138
|
-
constructor(http, snackBar, config, ngZone) {
|
|
139
|
-
this.http = http;
|
|
140
|
-
this.snackBar = snackBar;
|
|
141
|
-
this.config = config;
|
|
142
|
-
this.ngZone = ngZone;
|
|
143
|
-
this.analyticsRESTURL = config.analyticsRESTURL;
|
|
144
|
-
this.RESTURLPrefix = config.RESTURLPrefix;
|
|
145
|
-
}
|
|
146
|
-
getDateFormat(strVal, seprater) {
|
|
147
|
-
seprater = seprater ? seprater : '-';
|
|
148
|
-
const mydate = strVal;
|
|
149
|
-
return (mydate?.getFullYear() +
|
|
150
|
-
seprater +
|
|
151
|
-
((mydate ? mydate.getMonth() : 0) + 1) +
|
|
152
|
-
seprater +
|
|
153
|
-
mydate?.getDate());
|
|
154
|
-
}
|
|
155
|
-
getData(path) {
|
|
156
|
-
return this.http.get(`${this.analyticsRESTURL}${this.config.repository}/${path}`);
|
|
157
|
-
}
|
|
158
|
-
getRestData(path) {
|
|
159
|
-
return this.http.get(`${this.RESTURLPrefix}${path}`);
|
|
160
|
-
}
|
|
161
|
-
postdata(path, data) {
|
|
162
|
-
return this.http.post(`${this.analyticsRESTURL}${this.config.repository}/${path}`, data);
|
|
163
|
-
}
|
|
164
|
-
postDataWithRestUrl(path, data) {
|
|
165
|
-
return this.http.post(`${this.RESTURLPrefix}${path}`, data);
|
|
166
|
-
}
|
|
167
|
-
autocomplete(searchElementRef, type) {
|
|
168
|
-
return new Promise((resolve, reject) => {
|
|
169
|
-
const autocomplete = new google.maps.places.Autocomplete(searchElementRef.nativeElement, {
|
|
170
|
-
types: ['address']
|
|
171
|
-
});
|
|
172
|
-
google.maps.event.addListener(autocomplete, 'place_changed', () => {
|
|
173
|
-
this.ngZone.run(() => {
|
|
174
|
-
const place = autocomplete.getPlace();
|
|
175
|
-
resolve({ lat: place.geometry.location.lat(), lng: place.geometry.location.lng(), formatted_address: place['formatted_address'] });
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
openSnackBar(message, className) {
|
|
181
|
-
this.snackBar.open(message, '', {
|
|
182
|
-
duration: 5000,
|
|
183
|
-
verticalPosition: 'top',
|
|
184
|
-
horizontalPosition: 'center',
|
|
185
|
-
panelClass: [className ? className : 'default'],
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
makeOptions(item) {
|
|
189
|
-
if (item.order_number) {
|
|
190
|
-
this.jcodeOptions.findIndex((elem) => elem.job_id === item.job_id) === -1
|
|
191
|
-
? this.jcodeOptions.push({
|
|
192
|
-
job_code: item.order_number,
|
|
193
|
-
job_id: item.job_id,
|
|
194
|
-
})
|
|
195
|
-
: null;
|
|
196
|
-
if (item.driver_list && item.driver_list?.length > 0) {
|
|
197
|
-
item.driver_list.forEach((driver) => {
|
|
198
|
-
this.driverOption.findIndex((elem) => elem === driver['driver_name']) === -1
|
|
199
|
-
? this.driverOption.push(driver['driver_name'])
|
|
200
|
-
: null;
|
|
201
|
-
this.truckingCompanayOption.findIndex((elem) => elem === driver['trucking_company']) === -1
|
|
202
|
-
? this.truckingCompanayOption.push(driver['trucking_company'])
|
|
203
|
-
: null;
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
this.pickupOptions.findIndex((elem) => elem === item.pickup_location) === -1
|
|
208
|
-
? this.pickupOptions.push(item.pickup_location)
|
|
209
|
-
: null;
|
|
210
|
-
this.destOptions.findIndex((elem) => elem === item.delivery_location) === -1
|
|
211
|
-
? this.destOptions.push(item.delivery_location)
|
|
212
|
-
: null;
|
|
213
|
-
this.customerOptions.findIndex((customer) => customer === item.customer_name) === -1
|
|
214
|
-
? this.customerOptions.push(item.customer_name)
|
|
215
|
-
: null;
|
|
216
|
-
this.unitOptions.findIndex((elem) => elem === item.unit) === -1
|
|
217
|
-
? this.unitOptions.push(item.unit)
|
|
218
|
-
: null;
|
|
219
|
-
if (item.material) {
|
|
220
|
-
this.materialOptions.findIndex((elem) => elem === item.material) === -1
|
|
221
|
-
? this.materialOptions.push(item.material)
|
|
222
|
-
: null;
|
|
223
|
-
}
|
|
224
|
-
if (item.route_name)
|
|
225
|
-
this.routeNameOptions.findIndex((elem) => elem === item.route_name) === -1
|
|
226
|
-
? this.routeNameOptions.push(item.route_name)
|
|
227
|
-
: null;
|
|
228
|
-
}
|
|
229
|
-
filter(value, filters) {
|
|
230
|
-
if (typeof value !== 'string') {
|
|
231
|
-
return [];
|
|
232
|
-
}
|
|
233
|
-
const filterValue = value.toLowerCase();
|
|
234
|
-
if (filterValue === '') {
|
|
235
|
-
return [];
|
|
236
|
-
}
|
|
237
|
-
const searchResults = [];
|
|
238
|
-
this.unitOptions.map((unit) => {
|
|
239
|
-
if (unit.toLowerCase().includes(filterValue)) {
|
|
240
|
-
searchResults.push({ type: 'unit', label: unit, value: unit });
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
this.customerOptions.map((unit) => {
|
|
244
|
-
if (unit.toLowerCase().includes(filterValue)) {
|
|
245
|
-
searchResults.push({ type: 'customer', label: unit, value: unit });
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
if (this.materialOptions.length) {
|
|
249
|
-
this.materialOptions.map((unit) => {
|
|
250
|
-
if (unit.toLowerCase().includes(filterValue)) {
|
|
251
|
-
searchResults.push({ type: 'material', label: unit, value: unit });
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
this.pickupOptions.map((unit) => {
|
|
256
|
-
if (unit.toLowerCase().includes(filterValue)) {
|
|
257
|
-
searchResults.push({
|
|
258
|
-
type: 'pickup location',
|
|
259
|
-
label: unit,
|
|
260
|
-
value: unit,
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
this.destOptions.map((unit) => {
|
|
265
|
-
if (unit.toLowerCase().includes(filterValue)) {
|
|
266
|
-
searchResults.push({
|
|
267
|
-
type: 'destination location',
|
|
268
|
-
label: unit,
|
|
269
|
-
value: unit,
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
this.jcodeOptions.map((unit) => {
|
|
274
|
-
if (unit.job_code.toLowerCase().includes(filterValue)) {
|
|
275
|
-
searchResults.push({
|
|
276
|
-
type: 'job',
|
|
277
|
-
label: unit['job_code'],
|
|
278
|
-
value: unit,
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
this.driverOption.map((unit) => {
|
|
283
|
-
if (unit.toLowerCase().includes(filterValue)) {
|
|
284
|
-
searchResults.push({ type: 'Driver', label: unit, value: unit });
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
this.truckingCompanayOption.map((unit) => {
|
|
288
|
-
if (unit.toLowerCase().includes(filterValue)) {
|
|
289
|
-
searchResults.push({
|
|
290
|
-
type: 'Trucking Company',
|
|
291
|
-
label: unit,
|
|
292
|
-
value: unit,
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
this.routeNameOptions.map((unit) => {
|
|
297
|
-
if (unit.toLowerCase().includes(filterValue)) {
|
|
298
|
-
searchResults.push({ type: 'Route name', label: unit, value: unit });
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
const searchDict = {};
|
|
302
|
-
filters.map((filter) => {
|
|
303
|
-
searchDict[filter['name'] + filter['type']] = filter;
|
|
304
|
-
});
|
|
305
|
-
const furtherFilter = [];
|
|
306
|
-
searchResults.map((search) => {
|
|
307
|
-
if (search['label'] + search['type'] in searchDict) {
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
310
|
-
furtherFilter.push(search);
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
return furtherFilter;
|
|
314
|
-
}
|
|
315
|
-
getSearchResults(list, filterval) {
|
|
316
|
-
return list.filter((element) => {
|
|
317
|
-
const result_list_boolean = [];
|
|
318
|
-
if (filterval.length > 0) {
|
|
319
|
-
if (filterval[0]['type'] === 'unit') {
|
|
320
|
-
result_list_boolean.push(filterval[0]['name'] ===
|
|
321
|
-
element[filterval[0]['type']]);
|
|
322
|
-
}
|
|
323
|
-
if (filterval[0]['type'] === 'customer') {
|
|
324
|
-
result_list_boolean.push(filterval[0]['name'] === element['customer_name']);
|
|
325
|
-
}
|
|
326
|
-
if (filterval[0]['type'] === 'material') {
|
|
327
|
-
result_list_boolean.push(filterval[0]['name'] ===
|
|
328
|
-
element[filterval[0]['type']]);
|
|
329
|
-
}
|
|
330
|
-
if (filterval[0]['type'] === 'pickup location') {
|
|
331
|
-
result_list_boolean.push(filterval[0]['name'] === element['pickup_location']);
|
|
332
|
-
}
|
|
333
|
-
if (filterval[0]['type'] === 'destination location') {
|
|
334
|
-
result_list_boolean.push(filterval[0]['name'] === element['delivery_location']);
|
|
335
|
-
}
|
|
336
|
-
if (filterval[0]['type'] === 'job') {
|
|
337
|
-
result_list_boolean.push(filterval[0]['name'] === element['order_number']);
|
|
338
|
-
}
|
|
339
|
-
if (filterval[0]['type'] === 'Route name') {
|
|
340
|
-
result_list_boolean.push(filterval[0]['name'] === element['route_name']);
|
|
341
|
-
}
|
|
342
|
-
if (filterval[0]['type'] === 'Driver') {
|
|
343
|
-
const index = element.driver_list?.findIndex((ele) => {
|
|
344
|
-
return filterval[0]['name'] === ele['driver_name'];
|
|
345
|
-
});
|
|
346
|
-
if (index !== -1)
|
|
347
|
-
result_list_boolean.push(true);
|
|
348
|
-
}
|
|
349
|
-
if (filterval[0]['type'] === 'Trucking Company') {
|
|
350
|
-
const index = element.driver_list?.findIndex((ele) => {
|
|
351
|
-
return filterval[0]['name'] === ele['trucking_company'];
|
|
352
|
-
});
|
|
353
|
-
if (index !== -1)
|
|
354
|
-
result_list_boolean.push(true);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
if (result_list_boolean.length > 0) {
|
|
358
|
-
return result_list_boolean.reduce((prev, curr) => prev && curr);
|
|
359
|
-
}
|
|
360
|
-
return false;
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
clearOptions() {
|
|
364
|
-
this.pickupOptions = [];
|
|
365
|
-
this.destOptions = [];
|
|
366
|
-
this.ownerOptions = [];
|
|
367
|
-
this.customerOptions = [];
|
|
368
|
-
this.unitOptions = [];
|
|
369
|
-
this.materialOptions = [];
|
|
370
|
-
this.jcodeOptions = [];
|
|
371
|
-
this.routeNameOptions = [];
|
|
372
|
-
}
|
|
373
|
-
setdictValue(key, value) {
|
|
374
|
-
this.dict.set(key, value);
|
|
375
|
-
}
|
|
376
|
-
getdictValue(key) {
|
|
377
|
-
return JSON.parse(this.dict.get(key));
|
|
378
|
-
}
|
|
379
|
-
removedictValue(key) {
|
|
380
|
-
this.dict.delete(key);
|
|
381
|
-
}
|
|
382
|
-
conveySearchIcon(value) {
|
|
383
|
-
if (value && typeof value !== 'object')
|
|
384
|
-
return true;
|
|
385
|
-
return false;
|
|
386
|
-
}
|
|
387
|
-
fetchUnitsList() {
|
|
388
|
-
return new Promise((resolve, reject) => {
|
|
389
|
-
if (!this.unitsList) {
|
|
390
|
-
this.getData('unit/list/view').subscribe((res) => {
|
|
391
|
-
if (res) {
|
|
392
|
-
this.unitsList = res.data;
|
|
393
|
-
resolve(this.unitsList);
|
|
394
|
-
}
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
else {
|
|
398
|
-
resolve(this.unitsList);
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
fetchMaterialsList() {
|
|
403
|
-
return new Promise((resolve, reject) => {
|
|
404
|
-
if (!this.materialsList) {
|
|
405
|
-
this.getData('material/list/view').subscribe((res) => {
|
|
406
|
-
this.materialsList = this.filtermaterialList(res.data);
|
|
407
|
-
resolve(this.materialsList);
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
else {
|
|
411
|
-
resolve(this.materialsList);
|
|
412
|
-
}
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
fetchMaterialsListForCustomer() {
|
|
416
|
-
return new Promise((resolve, reject) => {
|
|
417
|
-
if (!this.materialsListForCustomer) {
|
|
418
|
-
this.getData('material/list/view').subscribe((res) => {
|
|
419
|
-
this.materialsListForCustomer = this.filtermaterialList(res.data);
|
|
420
|
-
resolve(this.materialsListForCustomer);
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
else {
|
|
424
|
-
resolve(this.materialsListForCustomer);
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
filtermaterialList(list) {
|
|
429
|
-
let meterialList = [];
|
|
430
|
-
list.map((item) => {
|
|
431
|
-
if (item.sub.length > 0) {
|
|
432
|
-
item.sub.map((subItem) => {
|
|
433
|
-
if (subItem.add_to_marketplace) {
|
|
434
|
-
subItem.material = item.material;
|
|
435
|
-
subItem.material_id = item.material_id;
|
|
436
|
-
subItem.label = item.material + ' | ' + subItem.sub_material;
|
|
437
|
-
meterialList.push(subItem);
|
|
438
|
-
}
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
});
|
|
442
|
-
meterialList.sort((a, b) => a.label.localeCompare(b.label));
|
|
443
|
-
return meterialList;
|
|
444
|
-
}
|
|
445
|
-
fetchCustomersList() {
|
|
446
|
-
return new Promise((resolve, reject) => {
|
|
447
|
-
if (!this.customersList) {
|
|
448
|
-
this.getData('company/list/view').subscribe((res) => {
|
|
449
|
-
if (res) {
|
|
450
|
-
this.customersList = res.data;
|
|
451
|
-
resolve(this.customersList);
|
|
452
|
-
}
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
else {
|
|
456
|
-
resolve(this.customersList);
|
|
457
|
-
}
|
|
458
|
-
});
|
|
459
|
-
}
|
|
460
|
-
fetchLocationlist() {
|
|
461
|
-
return new Promise((resolve, reject) => {
|
|
462
|
-
this.getRestData('locations/all').subscribe((res) => {
|
|
463
|
-
if (res) {
|
|
464
|
-
this.locationList = res.data;
|
|
465
|
-
this.locationList = this.locationList.map((object) => {
|
|
466
|
-
object.formatted_address = `${object.name} | ${object.street} ${object.city}, ${object.state} ${object.zip}`;
|
|
467
|
-
const newItem = {
|
|
468
|
-
city: object.city,
|
|
469
|
-
lng: object.longitude,
|
|
470
|
-
location_id: object.location_id,
|
|
471
|
-
lat: object.latitude,
|
|
472
|
-
name: object.name,
|
|
473
|
-
state: object.state,
|
|
474
|
-
street: object.street,
|
|
475
|
-
zip: object.zip,
|
|
476
|
-
formatted_address: object.formatted_address
|
|
477
|
-
};
|
|
478
|
-
return newItem;
|
|
479
|
-
});
|
|
480
|
-
resolve(this.locationList);
|
|
481
|
-
}
|
|
482
|
-
}, err => {
|
|
483
|
-
console.log(err);
|
|
484
|
-
});
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: UtilsService, deps: [{ token: i1.HttpClient }, { token: i2.MatSnackBar }, { token: 'memberData' }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
488
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: UtilsService, providedIn: 'root' });
|
|
489
|
-
}
|
|
490
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: UtilsService, decorators: [{
|
|
491
|
-
type: Injectable,
|
|
492
|
-
args: [{ providedIn: 'root' }]
|
|
493
|
-
}], ctorParameters: () => [{ type: i1.HttpClient }, { type: i2.MatSnackBar }, { type: CoolmapConfigModel, decorators: [{
|
|
494
|
-
type: Inject,
|
|
495
|
-
args: ['memberData']
|
|
496
|
-
}] }, { type: i0.NgZone }] });
|
|
497
|
-
|
|
498
|
-
class CoolmapService {
|
|
499
|
-
utils;
|
|
500
|
-
eventManager;
|
|
501
|
-
config;
|
|
502
|
-
map;
|
|
503
|
-
markerOriginList = [];
|
|
504
|
-
markerDestinationList = [];
|
|
505
|
-
initiatecoolmap = new BehaviorSubject(true);
|
|
506
|
-
reintiatecoolmap = this.initiatecoolmap.asObservable();
|
|
507
|
-
bounds = new mapboxgl.LngLatBounds();
|
|
508
|
-
originDestinationCordinates = [];
|
|
509
|
-
padding;
|
|
510
|
-
windowActualHeightWidth;
|
|
511
|
-
popup;
|
|
512
|
-
customTopForCustomer;
|
|
513
|
-
constructor(utils, eventManager, config) {
|
|
514
|
-
this.utils = utils;
|
|
515
|
-
this.eventManager = eventManager;
|
|
516
|
-
this.config = config;
|
|
517
|
-
this.customTopForCustomer = this.config.repository === 'customer' ? 65 : 0;
|
|
518
|
-
this.windowActualHeightWidth = { availHeight: 0 };
|
|
519
|
-
window.addEventListener('resize', this.onResize.bind(this));
|
|
520
|
-
}
|
|
521
|
-
initiateMapForAddRoute(el) {
|
|
522
|
-
return new Promise((resolve, reject) => {
|
|
523
|
-
if (this.map)
|
|
524
|
-
this.map.remove();
|
|
525
|
-
this.map = new mapboxgl.Map({
|
|
526
|
-
accessToken: this.config.mapboxAccessToken,
|
|
527
|
-
container: el,
|
|
528
|
-
style: this.config.mapboxStyle,
|
|
529
|
-
center: [-77.036873, 38.907192],
|
|
530
|
-
zoom: 10,
|
|
531
|
-
bearing: 0,
|
|
532
|
-
pitch: 65,
|
|
533
|
-
interactive: true,
|
|
534
|
-
});
|
|
535
|
-
this.map.once('load', (res) => {
|
|
536
|
-
resolve(res);
|
|
537
|
-
});
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
// Below method Load route with animation
|
|
541
|
-
loadMapProperty(pinRouteGeojson, index, unit, route, bottom) {
|
|
542
|
-
return new Promise((resolve, reject) => {
|
|
543
|
-
let origin = pinRouteGeojson.features[0].geometry.coordinates[0];
|
|
544
|
-
const linecolor = unit === 'Ton' ? '#ff7272' : unit === 'Load' ? '#a3c52e' : '#ae23d1';
|
|
545
|
-
let destination = pinRouteGeojson.features[0].geometry.coordinates[pinRouteGeojson.features[0].geometry.coordinates.length - 1];
|
|
546
|
-
this.extendBound(pinRouteGeojson.features[0].geometry.coordinates, true).then((res) => {
|
|
547
|
-
const point = {
|
|
548
|
-
type: 'FeatureCollection',
|
|
549
|
-
features: [
|
|
550
|
-
{
|
|
551
|
-
type: 'Feature',
|
|
552
|
-
properties: {},
|
|
553
|
-
geometry: { type: 'Point', coordinates: origin },
|
|
554
|
-
},
|
|
555
|
-
],
|
|
556
|
-
};
|
|
557
|
-
const lineDistance = turf.length(pinRouteGeojson.features[0]);
|
|
558
|
-
const arc = [];
|
|
559
|
-
const steps = 10 * pinRouteGeojson.features[0].geometry.coordinates.length;
|
|
560
|
-
for (let i = 0; i < lineDistance; i += lineDistance / steps) {
|
|
561
|
-
const segment = turf.along(pinRouteGeojson.features[0], i);
|
|
562
|
-
arc.push(segment.geometry.coordinates);
|
|
563
|
-
}
|
|
564
|
-
pinRouteGeojson.features[0].geometry.coordinates = arc;
|
|
565
|
-
const pinRoute = pinRouteGeojson.features[0].geometry.coordinates;
|
|
566
|
-
if (pinRoute && pinRoute.length) {
|
|
567
|
-
const marker = new mapboxgl.Marker(document.createElement('div'))
|
|
568
|
-
.setLngLat(pinRoute[0])
|
|
569
|
-
.addTo(this.map)
|
|
570
|
-
.togglePopup();
|
|
571
|
-
if (this.map.getSource(`line${index}`)) {
|
|
572
|
-
this.removeRouteAndMarker(index).then(() => { });
|
|
573
|
-
}
|
|
574
|
-
this.map.addSource(`line${index}`, {
|
|
575
|
-
type: 'geojson',
|
|
576
|
-
lineMetrics: true,
|
|
577
|
-
data: pinRouteGeojson,
|
|
578
|
-
});
|
|
579
|
-
this.map.addLayer({
|
|
580
|
-
type: 'line',
|
|
581
|
-
source: `line${index}`,
|
|
582
|
-
id: `line${index}`,
|
|
583
|
-
paint: {
|
|
584
|
-
'line-width': 2,
|
|
585
|
-
'line-gradient': [
|
|
586
|
-
'interpolate',
|
|
587
|
-
['linear'],
|
|
588
|
-
['line-progress'],
|
|
589
|
-
0,
|
|
590
|
-
unit === 'Ton'
|
|
591
|
-
? '#d7f7e4'
|
|
592
|
-
: unit === 'Load'
|
|
593
|
-
? '#c9d8f5'
|
|
594
|
-
: '#f5dcc1',
|
|
595
|
-
1,
|
|
596
|
-
unit === 'Ton'
|
|
597
|
-
? '#ff7272'
|
|
598
|
-
: unit === 'Load'
|
|
599
|
-
? '#a3c52e'
|
|
600
|
-
: '#ae23d1',
|
|
601
|
-
],
|
|
602
|
-
},
|
|
603
|
-
layout: { 'line-cap': 'round', 'line-join': 'round' },
|
|
604
|
-
});
|
|
605
|
-
const dataSetForMap = {
|
|
606
|
-
counter: 0,
|
|
607
|
-
pinRouteGeojson,
|
|
608
|
-
steps,
|
|
609
|
-
point,
|
|
610
|
-
pointId: `point${index}`,
|
|
611
|
-
marker,
|
|
612
|
-
pinRoute,
|
|
613
|
-
lineId: `line${index}`,
|
|
614
|
-
index,
|
|
615
|
-
origin,
|
|
616
|
-
destination,
|
|
617
|
-
lineDistance,
|
|
618
|
-
linecolor,
|
|
619
|
-
route,
|
|
620
|
-
isViewRoute: true,
|
|
621
|
-
};
|
|
622
|
-
this.createMarker(dataSetForMap);
|
|
623
|
-
this.map.on('mouseenter', `line${index}`, (e) => {
|
|
624
|
-
this.map.setPaintProperty(`line${index}`, 'line-width', 5);
|
|
625
|
-
this.map.setPaintProperty(`line${index}`, 'line-opacity', 1);
|
|
626
|
-
const datasetForPopup = {
|
|
627
|
-
coordinate: [e.lngLat.lng, e.lngLat.lat],
|
|
628
|
-
pickup: route.pickup_location ? route.pickup_location : '',
|
|
629
|
-
drop: route.delivery_location ? route.delivery_location : '',
|
|
630
|
-
routeType: route.project ? 'Project' : 'Route',
|
|
631
|
-
title: route.project
|
|
632
|
-
? route.project
|
|
633
|
-
: route.route_name
|
|
634
|
-
? route.route_name
|
|
635
|
-
: '',
|
|
636
|
-
material: route.material ? route.material : '',
|
|
637
|
-
type: route.unit ? route.unit : '',
|
|
638
|
-
};
|
|
639
|
-
if (this.popup)
|
|
640
|
-
this.popup.remove();
|
|
641
|
-
this.createPopup(datasetForPopup);
|
|
642
|
-
});
|
|
643
|
-
this.map.on('mouseleave', `line${index}`, (e) => {
|
|
644
|
-
this.map.setPaintProperty(`line${index}`, 'line-width', 2);
|
|
645
|
-
if (this.popup) {
|
|
646
|
-
this.popup.remove();
|
|
647
|
-
}
|
|
648
|
-
});
|
|
649
|
-
}
|
|
650
|
-
});
|
|
651
|
-
this.map.once('idle', (res) => {
|
|
652
|
-
resolve(true);
|
|
653
|
-
});
|
|
654
|
-
});
|
|
655
|
-
}
|
|
656
|
-
// Below method Load route without animation
|
|
657
|
-
drawLine(cordinates, index, route, enablefitbound, routeType) {
|
|
658
|
-
let linecolor;
|
|
659
|
-
let origin = cordinates[0];
|
|
660
|
-
let destination = cordinates[cordinates.length - 1];
|
|
661
|
-
if (origin[0] &&
|
|
662
|
-
origin[1] &&
|
|
663
|
-
destination &&
|
|
664
|
-
destination[0] &&
|
|
665
|
-
destination[1]) {
|
|
666
|
-
this.map.once('idle', (res) => {
|
|
667
|
-
linecolor = this.provideLineColor(route['unit'], routeType);
|
|
668
|
-
if (enablefitbound) {
|
|
669
|
-
const padding = {
|
|
670
|
-
top: this.padding.top + this.customTopForCustomer,
|
|
671
|
-
bottom: this.padding.bottom +
|
|
672
|
-
(this.windowActualHeightWidth.availHeight -
|
|
673
|
-
(window.innerHeight - 65)),
|
|
674
|
-
left: this.padding.left,
|
|
675
|
-
right: this.padding.right,
|
|
676
|
-
};
|
|
677
|
-
this.map.fitBounds([origin, destination], { padding, pitch: 65 }, { fitboundCompleteJob: true });
|
|
678
|
-
}
|
|
679
|
-
if (this.map.getSource(`route-source-for-job-code${index}`)) {
|
|
680
|
-
this.removeRouteAndMarker(index).then(() => { });
|
|
681
|
-
}
|
|
682
|
-
this.map.addSource(`route-source-for-job-code${index}`, {
|
|
683
|
-
type: 'geojson',
|
|
684
|
-
data: {
|
|
685
|
-
type: 'Feature',
|
|
686
|
-
properties: {},
|
|
687
|
-
geometry: { type: 'LineString', coordinates: cordinates },
|
|
688
|
-
},
|
|
689
|
-
});
|
|
690
|
-
this.map.addLayer({
|
|
691
|
-
id: `route-for-job-code${index}`,
|
|
692
|
-
type: 'line',
|
|
693
|
-
source: `route-source-for-job-code${index}`,
|
|
694
|
-
paint: { 'line-color': linecolor, 'line-width': 2 },
|
|
695
|
-
layout: { 'line-cap': 'round', 'line-join': 'round' },
|
|
696
|
-
});
|
|
697
|
-
const dataSetForMap = {
|
|
698
|
-
origin,
|
|
699
|
-
destination,
|
|
700
|
-
index,
|
|
701
|
-
linecolor,
|
|
702
|
-
route,
|
|
703
|
-
};
|
|
704
|
-
this.createMarker(dataSetForMap);
|
|
705
|
-
this.map.on('mouseenter', `route-for-job-code${index}`, (e) => {
|
|
706
|
-
if (this.popup) {
|
|
707
|
-
this.popup.remove();
|
|
708
|
-
}
|
|
709
|
-
this.map.setPaintProperty(`route-for-job-code${index}`, 'line-width', 5);
|
|
710
|
-
this.map.setPaintProperty(`route-for-job-code${index}`, 'line-opacity', 1);
|
|
711
|
-
const datasetForPopup = {
|
|
712
|
-
coordinate: [e.lngLat.lng, e.lngLat.lat],
|
|
713
|
-
pickup: route.pickup_location ? route.pickup_location : '',
|
|
714
|
-
drop: route.delivery_location ? route.delivery_location : '',
|
|
715
|
-
jobCode: route.project ? route.order_number : null,
|
|
716
|
-
customer: route.project ? route.customer_name : null,
|
|
717
|
-
routeType: route.project ? 'Project' : 'Route',
|
|
718
|
-
title: route.project
|
|
719
|
-
? route.project
|
|
720
|
-
: route.route_name
|
|
721
|
-
? route.route_name
|
|
722
|
-
: '',
|
|
723
|
-
material: route.material ? route.material : '',
|
|
724
|
-
type: route.unit ? route.unit : '',
|
|
725
|
-
};
|
|
726
|
-
this.createPopup(datasetForPopup);
|
|
727
|
-
});
|
|
728
|
-
this.map.on('mouseleave', `route-for-job-code${index}`, (e) => {
|
|
729
|
-
this.map.setPaintProperty(`route-for-job-code${index}`, 'line-width', 2);
|
|
730
|
-
if (this.popup) {
|
|
731
|
-
this.popup.remove();
|
|
732
|
-
}
|
|
733
|
-
});
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
provideLineColor(unitType, type) {
|
|
738
|
-
let checkType = type && !['jobrouteList', 'addroute'].includes(type) ? true : false;
|
|
739
|
-
let color;
|
|
740
|
-
switch (unitType) {
|
|
741
|
-
case 'Ton':
|
|
742
|
-
color = checkType ? '#39c471' : '#ff7272';
|
|
743
|
-
break;
|
|
744
|
-
case 'Load':
|
|
745
|
-
color = checkType ? '#326ad3' : '#a3c52e';
|
|
746
|
-
break;
|
|
747
|
-
case 'Hourly':
|
|
748
|
-
color = checkType ? '#ffad56' : '#ae23d1';
|
|
749
|
-
break;
|
|
750
|
-
}
|
|
751
|
-
return color;
|
|
752
|
-
}
|
|
753
|
-
showRoutePopup(arcDetails, event, isViewRoute) {
|
|
754
|
-
if (this.popup) {
|
|
755
|
-
this.popup.remove();
|
|
756
|
-
this.map.setPaintProperty(`${isViewRoute ? 'line' : 'route-for-job-code'}${arcDetails.layer.props.data.index}`, 'line-width', 2);
|
|
757
|
-
}
|
|
758
|
-
if (arcDetails.color &&
|
|
759
|
-
this.map.getLayoutProperty(arcDetails.layer.id, 'visibility') !== 'none') {
|
|
760
|
-
this.map.setPaintProperty(`${isViewRoute ? 'line' : 'route-for-job-code'}${arcDetails.layer.props.data.index}`, 'line-width', 5);
|
|
761
|
-
this.map.setPaintProperty(`${isViewRoute ? 'line' : 'route-for-job-code'}${arcDetails.layer.props.data.index}`, 'line-opacity', 1);
|
|
762
|
-
const datasetForPopup = {
|
|
763
|
-
coordinate: arcDetails.coordinate,
|
|
764
|
-
pickup: arcDetails.layer.props.data.route.pickup_location
|
|
765
|
-
? arcDetails.layer.props.data.route.pickup_location
|
|
766
|
-
: '',
|
|
767
|
-
drop: arcDetails.layer.props.data.route.delivery_location
|
|
768
|
-
? arcDetails.layer.props.data.route.delivery_location
|
|
769
|
-
: '',
|
|
770
|
-
jobCode: arcDetails.layer.props.data.route.project
|
|
771
|
-
? arcDetails.layer.props.data.route.order_number
|
|
772
|
-
: '',
|
|
773
|
-
customer: arcDetails.layer.props.data.route.project
|
|
774
|
-
? arcDetails.layer.props.data.route.customer_name
|
|
775
|
-
: '',
|
|
776
|
-
routeType: arcDetails.layer.props.data.route.project
|
|
777
|
-
? 'Project'
|
|
778
|
-
: 'Route',
|
|
779
|
-
title: arcDetails.layer.props.data.route.project
|
|
780
|
-
? arcDetails.layer.props.data.route.project
|
|
781
|
-
: arcDetails.layer.props.data.route.route_name
|
|
782
|
-
? arcDetails.layer.props.data.route.route_name
|
|
783
|
-
: '',
|
|
784
|
-
material: arcDetails.layer.props.data.route.material
|
|
785
|
-
? arcDetails.layer.props.data.route.material
|
|
786
|
-
: '',
|
|
787
|
-
type: arcDetails.layer.props.data.route.unit
|
|
788
|
-
? arcDetails.layer.props.data.route.unit
|
|
789
|
-
: '',
|
|
790
|
-
};
|
|
791
|
-
this.createPopup(datasetForPopup);
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
createPopup(datasetForPopup) {
|
|
795
|
-
this.popup = new mapboxgl.Popup({
|
|
796
|
-
closeButton: false,
|
|
797
|
-
closeOnClick: false,
|
|
798
|
-
closeOnMove: true,
|
|
799
|
-
anchor: 'bottom-left',
|
|
800
|
-
});
|
|
801
|
-
this.popup
|
|
802
|
-
.setLngLat(datasetForPopup.coordinate)
|
|
803
|
-
.setHTML(`<div class="destination">
|
|
804
|
-
<div class="duration">
|
|
805
|
-
<p class="pickprt"><b>Pickup Location:</b> ${datasetForPopup.pickup?.split('|')[1] ? datasetForPopup.pickup.split('|')[1] : datasetForPopup.pickup}</p>
|
|
806
|
-
<p class="dropprt"><b>Drop Location:</b> ${datasetForPopup.drop?.split('|')[1] ?
|
|
807
|
-
datasetForPopup.drop.split('|')[1] :
|
|
808
|
-
datasetForPopup.drop}</p>
|
|
809
|
-
</div>
|
|
810
|
-
${datasetForPopup.jobCode
|
|
811
|
-
? '<span><b>Job Code:</b> ' + datasetForPopup.jobCode + '</span>'
|
|
812
|
-
: ''}
|
|
813
|
-
${datasetForPopup.customer
|
|
814
|
-
? '<span><b>Customer:</b> ' + datasetForPopup.customer + '</span>'
|
|
815
|
-
: ''}
|
|
816
|
-
<span>
|
|
817
|
-
<b>${datasetForPopup.routeType} Name:</b>
|
|
818
|
-
${datasetForPopup.title}
|
|
819
|
-
</span>
|
|
820
|
-
${datasetForPopup.material
|
|
821
|
-
? '<span><b>Material:</b> ' + datasetForPopup.material + '</span>'
|
|
822
|
-
: ''}
|
|
823
|
-
<span><b>Type:</b> ${datasetForPopup.type}</span>
|
|
824
|
-
</div>`)
|
|
825
|
-
.addTo(this.map);
|
|
826
|
-
}
|
|
827
|
-
hexToRGB(hex) {
|
|
828
|
-
return hex
|
|
829
|
-
.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (m, r, g, b) => '#' + r + r + g + g + b + b)
|
|
830
|
-
.substring(1)
|
|
831
|
-
.match(/.{2}/g)
|
|
832
|
-
.map((x) => parseInt(x, 16));
|
|
833
|
-
}
|
|
834
|
-
createMarker(routeDetails) {
|
|
835
|
-
if (routeDetails.origin[0] &&
|
|
836
|
-
routeDetails.origin[1] &&
|
|
837
|
-
routeDetails.destination[0] &&
|
|
838
|
-
routeDetails.destination[1]) {
|
|
839
|
-
const popup = new mapboxgl.Popup({ closeButton: false }).setHTML('<b>Pickup: </b>' + routeDetails.route?.pickup_location);
|
|
840
|
-
const popupForDestination = new mapboxgl.Popup({
|
|
841
|
-
closeButton: false,
|
|
842
|
-
}).setHTML('<b>Delivery: </b>' + routeDetails.route?.delivery_location);
|
|
843
|
-
const el = document.createElement('div');
|
|
844
|
-
el.className = 'marker';
|
|
845
|
-
el.innerHTML = `<span class='markerPointer' style='background:${routeDetails.linecolor}'><b>P</b><span class='markerSpan' style='border-top: 10px solid ${routeDetails.linecolor}'></span></span>`;
|
|
846
|
-
const originMarker = new mapboxgl.Marker(el)
|
|
847
|
-
.setPopup(popup)
|
|
848
|
-
.setLngLat(routeDetails.origin)
|
|
849
|
-
.addTo(this.map);
|
|
850
|
-
originMarker
|
|
851
|
-
.getElement()
|
|
852
|
-
.addEventListener('mouseenter', () => originMarker.togglePopup());
|
|
853
|
-
originMarker
|
|
854
|
-
.getElement()
|
|
855
|
-
.addEventListener('mouseleave', () => originMarker.togglePopup());
|
|
856
|
-
const elementForDestination = document.createElement('div');
|
|
857
|
-
elementForDestination.className = 'marker';
|
|
858
|
-
elementForDestination.innerHTML = `<span class='markerPointer' style='background:${routeDetails.linecolor}'><b>D</b><span class='markerSpan' style='border-top: 10px solid ${routeDetails.linecolor}'></span></span>`;
|
|
859
|
-
const destinationMarker = new mapboxgl.Marker(elementForDestination)
|
|
860
|
-
.setPopup(popupForDestination)
|
|
861
|
-
.setLngLat(routeDetails.destination)
|
|
862
|
-
.addTo(this.map);
|
|
863
|
-
destinationMarker
|
|
864
|
-
.getElement()
|
|
865
|
-
.addEventListener('mouseenter', () => destinationMarker.togglePopup());
|
|
866
|
-
destinationMarker
|
|
867
|
-
.getElement()
|
|
868
|
-
.addEventListener('mouseleave', () => destinationMarker.togglePopup());
|
|
869
|
-
this.markerOriginList[routeDetails.index] = originMarker;
|
|
870
|
-
this.markerDestinationList[routeDetails.index] = destinationMarker;
|
|
871
|
-
const colorArray = this.hexToRGB(routeDetails.linecolor);
|
|
872
|
-
const arcLayer = new MapboxLayer({
|
|
873
|
-
id: 'arc-layer' + routeDetails.index,
|
|
874
|
-
type: ArcLayer,
|
|
875
|
-
pickable: true,
|
|
876
|
-
data: { route: routeDetails.route, index: routeDetails.index },
|
|
877
|
-
getWidth: 1,
|
|
878
|
-
getSourcePosition: routeDetails.origin,
|
|
879
|
-
getTargetPosition: routeDetails.destination,
|
|
880
|
-
getTargetColor: [255, 255, 255],
|
|
881
|
-
getSourceColor: [colorArray[0], colorArray[1], colorArray[2]],
|
|
882
|
-
onHover: (info, event) => this.showRoutePopup(info, event, routeDetails.isViewRoute),
|
|
883
|
-
});
|
|
884
|
-
this.map.addLayer(arcLayer);
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
async removeRouteAndMarker(index) {
|
|
888
|
-
if (this.map) {
|
|
889
|
-
this.map.getLayer(`arc-layer${index}`)
|
|
890
|
-
? this.map.removeLayer(`arc-layer${index}`)
|
|
891
|
-
: '';
|
|
892
|
-
this.map.getLayer(`line${index}`)
|
|
893
|
-
? this.map.removeLayer(`line${index}`)
|
|
894
|
-
: '';
|
|
895
|
-
this.map.getLayer(`custom_layer${index}`)
|
|
896
|
-
? this.map.removeLayer(`custom_layer${index}`)
|
|
897
|
-
: '';
|
|
898
|
-
this.map.getSource(`line${index}`)
|
|
899
|
-
? this.map.removeSource(`line${index}`)
|
|
900
|
-
: '';
|
|
901
|
-
this.map.getLayer(`route-for-job-code${index}`)
|
|
902
|
-
? this.map.removeLayer(`route-for-job-code${index}`)
|
|
903
|
-
: '';
|
|
904
|
-
this.map.getSource(`route-source-for-job-code${index}`)
|
|
905
|
-
? this.map.removeSource(`route-source-for-job-code${index}`)
|
|
906
|
-
: '';
|
|
907
|
-
this.findMarkerBound(index);
|
|
908
|
-
this.markerOriginList[index] ? this.markerOriginList[index].remove() : '';
|
|
909
|
-
this.markerDestinationList[index]
|
|
910
|
-
? this.markerDestinationList[index].remove()
|
|
911
|
-
: '';
|
|
912
|
-
await true;
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
findMarkerBound(index) {
|
|
916
|
-
const indexOfCordinates = this.originDestinationCordinates.findIndex((x) => x[0][0].toFixed(6) ==
|
|
917
|
-
this.markerOriginList[index]?.getLngLat()?.lng.toFixed(6) &&
|
|
918
|
-
x[0][1].toFixed(6) ==
|
|
919
|
-
this.markerOriginList[index]?.getLngLat()?.lat.toFixed(6));
|
|
920
|
-
if (indexOfCordinates >= 0) {
|
|
921
|
-
this.originDestinationCordinates.splice(indexOfCordinates, 1);
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
async filterRoute(ID, visibility, showAllFitbound) {
|
|
925
|
-
if (ID) {
|
|
926
|
-
if (this.map.getLayer(`route-for-job-code${ID}`)) {
|
|
927
|
-
this.map.setLayoutProperty(`route-for-job-code${ID}`, 'visibility', visibility);
|
|
928
|
-
const originM = this.markerOriginList[ID].getElement();
|
|
929
|
-
originM.style.display = visibility === 'visible' ? 'block' : visibility;
|
|
930
|
-
const destinationM = this.markerDestinationList[ID].getElement();
|
|
931
|
-
destinationM.style.display =
|
|
932
|
-
visibility === 'visible' ? 'block' : visibility;
|
|
933
|
-
if (visibility === 'none' && showAllFitbound) {
|
|
934
|
-
this.findMarkerBound(ID);
|
|
935
|
-
this.extendReBound();
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
if (this.map.getLayer(`arc-layer${ID}`)) {
|
|
939
|
-
this.map.setLayoutProperty(`arc-layer${ID}`, 'visibility', visibility);
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
await true;
|
|
943
|
-
}
|
|
944
|
-
extendBound(route, showAllFitbound) {
|
|
945
|
-
return new Promise((resolve, reject) => {
|
|
946
|
-
if (route) {
|
|
947
|
-
if (typeof route === 'string') {
|
|
948
|
-
let path = route.split(';');
|
|
949
|
-
path = path.map((ele) => {
|
|
950
|
-
return (ele = this.formateLatLong(ele));
|
|
951
|
-
});
|
|
952
|
-
path.forEach((ele, index) => {
|
|
953
|
-
if (ele.length === 1)
|
|
954
|
-
path.splice(index, 1);
|
|
955
|
-
});
|
|
956
|
-
route = path;
|
|
957
|
-
}
|
|
958
|
-
if (route[0][0] &&
|
|
959
|
-
route[0][1] &&
|
|
960
|
-
route[route.length - 1][0] &&
|
|
961
|
-
route[route.length - 1][1]) {
|
|
962
|
-
this.originDestinationCordinates.push(route);
|
|
963
|
-
route.map((item) => {
|
|
964
|
-
this.bounds.extend(item);
|
|
965
|
-
});
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
if (showAllFitbound) {
|
|
969
|
-
setTimeout(() => {
|
|
970
|
-
if (showAllFitbound && Object.keys(this.bounds).length > 0)
|
|
971
|
-
this.map.fitBounds(this.bounds, { pitch: 65 }, { fitboundComplete: true });
|
|
972
|
-
}, 100);
|
|
973
|
-
this.map.once('moveend', (event) => {
|
|
974
|
-
if (event.fitboundComplete) {
|
|
975
|
-
resolve(true);
|
|
976
|
-
}
|
|
977
|
-
});
|
|
978
|
-
}
|
|
979
|
-
});
|
|
980
|
-
}
|
|
981
|
-
extendReBound(bottom) {
|
|
982
|
-
return new Promise((resolve, reject) => {
|
|
983
|
-
this.bounds = new mapboxgl.LngLatBounds();
|
|
984
|
-
if (this.originDestinationCordinates.length >= 0) {
|
|
985
|
-
this.originDestinationCordinates.map((item, index) => {
|
|
986
|
-
item.map((route) => {
|
|
987
|
-
this.bounds.extend(route);
|
|
988
|
-
});
|
|
989
|
-
if (index === this.originDestinationCordinates.length - 1) {
|
|
990
|
-
const padding = {
|
|
991
|
-
top: this.padding.top + this.customTopForCustomer,
|
|
992
|
-
bottom: this.padding.bottom +
|
|
993
|
-
(this.windowActualHeightWidth.availHeight -
|
|
994
|
-
(window.innerHeight - 65)),
|
|
995
|
-
left: this.padding.left,
|
|
996
|
-
right: this.padding.right,
|
|
997
|
-
};
|
|
998
|
-
setTimeout(() => {
|
|
999
|
-
if (this.originDestinationCordinates.length > 0)
|
|
1000
|
-
this.map.fitBounds(this.bounds, { padding, pitch: 65 });
|
|
1001
|
-
}, 500);
|
|
1002
|
-
resolve(true);
|
|
1003
|
-
}
|
|
1004
|
-
});
|
|
1005
|
-
}
|
|
1006
|
-
else {
|
|
1007
|
-
resolve(true);
|
|
1008
|
-
}
|
|
1009
|
-
});
|
|
1010
|
-
}
|
|
1011
|
-
plotRoute(route, i, type, enablefitbound, showAllFitbound) {
|
|
1012
|
-
return new Promise((resolve, reject) => {
|
|
1013
|
-
let param = {};
|
|
1014
|
-
if (['jobcode'].includes(type)) {
|
|
1015
|
-
param['job'] = route['job_id'];
|
|
1016
|
-
this.utils.postDataWithRestUrl('schedule/job/path', param).subscribe((res) => {
|
|
1017
|
-
if (res['data']['route']) {
|
|
1018
|
-
let path = res['data']['route'].split(';');
|
|
1019
|
-
path = path.map((ele) => {
|
|
1020
|
-
return (ele = this.formateLatLong(ele));
|
|
1021
|
-
});
|
|
1022
|
-
path.forEach((ele, index) => {
|
|
1023
|
-
if (ele.length === 1)
|
|
1024
|
-
path.splice(index, 1);
|
|
1025
|
-
});
|
|
1026
|
-
route['path'] = path;
|
|
1027
|
-
this.extendBound(route['path'], showAllFitbound);
|
|
1028
|
-
if (route['path'] && route['path'].length > 0)
|
|
1029
|
-
this.drawLine(route['path'], i, route, enablefitbound, type);
|
|
1030
|
-
route['index'] = i;
|
|
1031
|
-
}
|
|
1032
|
-
else {
|
|
1033
|
-
this.extendBound(null, showAllFitbound);
|
|
1034
|
-
}
|
|
1035
|
-
resolve(true);
|
|
1036
|
-
}, (err) => {
|
|
1037
|
-
if (err) {
|
|
1038
|
-
reject(false);
|
|
1039
|
-
}
|
|
1040
|
-
});
|
|
1041
|
-
}
|
|
1042
|
-
else if (['jobrouteList', 'addroute'].includes(type)) {
|
|
1043
|
-
if (route['path'] && route['path'].length > 0) {
|
|
1044
|
-
let path = route['path'].split(';');
|
|
1045
|
-
path = path.map((ele) => {
|
|
1046
|
-
return (ele = this.formateLatLong(ele));
|
|
1047
|
-
});
|
|
1048
|
-
path.forEach((ele, index) => {
|
|
1049
|
-
if (ele.length === 1)
|
|
1050
|
-
path.splice(index, 1);
|
|
1051
|
-
});
|
|
1052
|
-
this.extendBound(path, showAllFitbound);
|
|
1053
|
-
this.drawLine(path, i, route, enablefitbound, type);
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
});
|
|
1057
|
-
}
|
|
1058
|
-
clearBound() {
|
|
1059
|
-
this.bounds = new mapboxgl.LngLatBounds();
|
|
1060
|
-
this.originDestinationCordinates = [];
|
|
1061
|
-
this.clearPadding();
|
|
1062
|
-
}
|
|
1063
|
-
formateLatLong(latlong) {
|
|
1064
|
-
return latlong
|
|
1065
|
-
? latlong
|
|
1066
|
-
.split(',')
|
|
1067
|
-
.map((x) => +x)
|
|
1068
|
-
.reverse()
|
|
1069
|
-
: null;
|
|
1070
|
-
}
|
|
1071
|
-
clearBoundWithCordinates() {
|
|
1072
|
-
this.bounds = new mapboxgl.LngLatBounds();
|
|
1073
|
-
this.originDestinationCordinates = [];
|
|
1074
|
-
}
|
|
1075
|
-
onResize(event) {
|
|
1076
|
-
if (!this.bounds.isEmpty()) {
|
|
1077
|
-
this.windowActualHeightWidth.availHeight =
|
|
1078
|
-
window.innerHeight > window.screen.availHeight
|
|
1079
|
-
? window.innerHeight
|
|
1080
|
-
: window.screen.availHeight;
|
|
1081
|
-
setTimeout(() => {
|
|
1082
|
-
this.map.fitBounds(this.bounds, {
|
|
1083
|
-
padding: {
|
|
1084
|
-
top: this.padding.top + this.customTopForCustomer,
|
|
1085
|
-
bottom: this.padding.bottom +
|
|
1086
|
-
(this.windowActualHeightWidth.availHeight -
|
|
1087
|
-
(event.target.innerHeight - 65)),
|
|
1088
|
-
left: this.padding.left,
|
|
1089
|
-
right: this.padding.right,
|
|
1090
|
-
},
|
|
1091
|
-
pitch: 65,
|
|
1092
|
-
});
|
|
1093
|
-
}, 500);
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
setWindowHeight(screen) {
|
|
1097
|
-
this.windowActualHeightWidth.availHeight = screen;
|
|
1098
|
-
}
|
|
1099
|
-
setPadding(padding) {
|
|
1100
|
-
this.padding = padding;
|
|
1101
|
-
}
|
|
1102
|
-
clearPadding() {
|
|
1103
|
-
this.padding = null;
|
|
1104
|
-
}
|
|
1105
|
-
removeJobFromMap(data) {
|
|
1106
|
-
data.map((ele, index) => {
|
|
1107
|
-
const id = ele['job_id'] ? ele['job_id'] : ele['route_id'];
|
|
1108
|
-
this.removeRouteAndMarker(id);
|
|
1109
|
-
if (index === data.length - 1) {
|
|
1110
|
-
this.extendReBound();
|
|
1111
|
-
}
|
|
1112
|
-
});
|
|
1113
|
-
}
|
|
1114
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CoolmapService, deps: [{ token: UtilsService }, { token: i2$1.EventManager }, { token: 'memberData' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1115
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CoolmapService, providedIn: 'root' });
|
|
1116
|
-
}
|
|
1117
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CoolmapService, decorators: [{
|
|
1118
|
-
type: Injectable,
|
|
1119
|
-
args: [{ providedIn: 'root' }]
|
|
1120
|
-
}], ctorParameters: () => [{ type: UtilsService }, { type: i2$1.EventManager }, { type: CoolmapConfigModel, decorators: [{
|
|
1121
|
-
type: Inject,
|
|
1122
|
-
args: ['memberData']
|
|
1123
|
-
}] }] });
|
|
1124
|
-
|
|
1125
|
-
/*
|
|
1126
|
-
* Public API Surface of @aggdirect/coolmap-services
|
|
1127
|
-
*/
|
|
1128
|
-
|
|
1129
|
-
/**
|
|
1130
|
-
* Generated bundle index. Do not edit.
|
|
1131
|
-
*/
|
|
1132
|
-
|
|
1133
|
-
export { CoolmapConfigModel, CoolmapService, DriverSmsCardEnum, DriversmsCardKey, EstinationData, EstinationEnum, JobCodeOverviewData, JobCodeOverviewEnum, PopupData, Route, UtilsService };
|
|
1134
|
-
//# sourceMappingURL=aggdirect-coolmap-services.mjs.map
|