Showing
12 changed files
with
138 additions
and
72 deletions
... | ... | @@ -1897,6 +1897,15 @@ |
1897 | 1897 | "@types/geojson": "*" |
1898 | 1898 | } |
1899 | 1899 | }, |
1900 | + "@types/leaflet-polylinedecorator": { | |
1901 | + "version": "1.6.0", | |
1902 | + "resolved": "https://registry.npmjs.org/@types/leaflet-polylinedecorator/-/leaflet-polylinedecorator-1.6.0.tgz", | |
1903 | + "integrity": "sha512-Z2BXZDjKEqHclwrAmhYdF1RwyFfa/NFxsoF79sitzaj5D/4YWHp/zDRcUZar5cQFKRgK66AYEIF7nKVuMzUGdw==", | |
1904 | + "dev": true, | |
1905 | + "requires": { | |
1906 | + "@types/leaflet": "*" | |
1907 | + } | |
1908 | + }, | |
1900 | 1909 | "@types/lodash": { |
1901 | 1910 | "version": "4.14.149", |
1902 | 1911 | "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.149.tgz", |
... | ... | @@ -8274,11 +8283,24 @@ |
8274 | 8283 | "leaflet": ">=0.7.0" |
8275 | 8284 | } |
8276 | 8285 | }, |
8286 | + "leaflet-polylinedecorator": { | |
8287 | + "version": "1.6.0", | |
8288 | + "resolved": "https://registry.npmjs.org/leaflet-polylinedecorator/-/leaflet-polylinedecorator-1.6.0.tgz", | |
8289 | + "integrity": "sha1-nvef0bUwLWe3Lv6Vmo7NJVPycmY=", | |
8290 | + "requires": { | |
8291 | + "leaflet-rotatedmarker": "^0.2.0" | |
8292 | + } | |
8293 | + }, | |
8277 | 8294 | "leaflet-providers": { |
8278 | 8295 | "version": "1.9.1", |
8279 | 8296 | "resolved": "https://registry.npmjs.org/leaflet-providers/-/leaflet-providers-1.9.1.tgz", |
8280 | 8297 | "integrity": "sha512-YpJB9y4/nT5NGicU9vuqlttJaCer6paD3J3b8Wrw+IIQvK9dtcdzE9CsTkDg7Dg9FeGp5NEr3hu17xcHbYI/2w==" |
8281 | 8298 | }, |
8299 | + "leaflet-rotatedmarker": { | |
8300 | + "version": "0.2.0", | |
8301 | + "resolved": "https://registry.npmjs.org/leaflet-rotatedmarker/-/leaflet-rotatedmarker-0.2.0.tgz", | |
8302 | + "integrity": "sha1-RGf0n5jRv9VpWb2cZwUgPdJgEnc=" | |
8303 | + }, | |
8282 | 8304 | "leaflet.gridlayer.googlemutant": { |
8283 | 8305 | "version": "0.8.0", |
8284 | 8306 | "resolved": "https://registry.npmjs.org/leaflet.gridlayer.googlemutant/-/leaflet.gridlayer.googlemutant-0.8.0.tgz", |
... | ... | @@ -14425,7 +14447,7 @@ |
14425 | 14447 | "dev": true, |
14426 | 14448 | "optional": true, |
14427 | 14449 | "requires": { |
14428 | - "balanced-match": "1.0.0", | |
14450 | + "balanced-match": "^1.0.0", | |
14429 | 14451 | "concat-map": "0.0.1" |
14430 | 14452 | } |
14431 | 14453 | }, |
... | ... | @@ -14465,7 +14487,7 @@ |
14465 | 14487 | "dev": true, |
14466 | 14488 | "optional": true, |
14467 | 14489 | "requires": { |
14468 | - "ms": "2.1.2" | |
14490 | + "ms": "^2.1.1" | |
14469 | 14491 | } |
14470 | 14492 | }, |
14471 | 14493 | "deep-extend": { |
... | ... | @@ -14552,7 +14574,7 @@ |
14552 | 14574 | "dev": true, |
14553 | 14575 | "optional": true, |
14554 | 14576 | "requires": { |
14555 | - "minimatch": "3.0.4" | |
14577 | + "minimatch": "^3.0.4" | |
14556 | 14578 | } |
14557 | 14579 | }, |
14558 | 14580 | "inflight": { |
... | ... | @@ -14583,7 +14605,7 @@ |
14583 | 14605 | "dev": true, |
14584 | 14606 | "optional": true, |
14585 | 14607 | "requires": { |
14586 | - "number-is-nan": "1.0.1" | |
14608 | + "number-is-nan": "^1.0.0" | |
14587 | 14609 | } |
14588 | 14610 | }, |
14589 | 14611 | "isarray": { |
... | ... | @@ -14598,7 +14620,7 @@ |
14598 | 14620 | "dev": true, |
14599 | 14621 | "optional": true, |
14600 | 14622 | "requires": { |
14601 | - "brace-expansion": "1.1.11" | |
14623 | + "brace-expansion": "^1.1.7" | |
14602 | 14624 | } |
14603 | 14625 | }, |
14604 | 14626 | "minimist": { |
... | ... | @@ -14676,8 +14698,8 @@ |
14676 | 14698 | "dev": true, |
14677 | 14699 | "optional": true, |
14678 | 14700 | "requires": { |
14679 | - "abbrev": "1.1.1", | |
14680 | - "osenv": "0.1.5" | |
14701 | + "abbrev": "1", | |
14702 | + "osenv": "^0.1.4" | |
14681 | 14703 | } |
14682 | 14704 | }, |
14683 | 14705 | "npm-bundled": { |
... | ... | @@ -14686,7 +14708,7 @@ |
14686 | 14708 | "dev": true, |
14687 | 14709 | "optional": true, |
14688 | 14710 | "requires": { |
14689 | - "npm-normalize-package-bin": "1.0.1" | |
14711 | + "npm-normalize-package-bin": "^1.0.1" | |
14690 | 14712 | } |
14691 | 14713 | }, |
14692 | 14714 | "npm-normalize-package-bin": { |
... | ... | @@ -14701,8 +14723,8 @@ |
14701 | 14723 | "dev": true, |
14702 | 14724 | "optional": true, |
14703 | 14725 | "requires": { |
14704 | - "ignore-walk": "3.0.3", | |
14705 | - "npm-bundled": "1.1.1" | |
14726 | + "ignore-walk": "^3.0.1", | |
14727 | + "npm-bundled": "^1.0.1" | |
14706 | 14728 | } |
14707 | 14729 | }, |
14708 | 14730 | "npmlog": { |
... | ... | @@ -14756,8 +14778,8 @@ |
14756 | 14778 | "dev": true, |
14757 | 14779 | "optional": true, |
14758 | 14780 | "requires": { |
14759 | - "os-homedir": "1.0.2", | |
14760 | - "os-tmpdir": "1.0.2" | |
14781 | + "os-homedir": "^1.0.0", | |
14782 | + "os-tmpdir": "^1.0.0" | |
14761 | 14783 | } |
14762 | 14784 | }, |
14763 | 14785 | "path-is-absolute": { |
... | ... | @@ -15398,7 +15420,7 @@ |
15398 | 15420 | "dev": true, |
15399 | 15421 | "optional": true, |
15400 | 15422 | "requires": { |
15401 | - "ms": "2.1.2" | |
15423 | + "ms": "^2.1.1" | |
15402 | 15424 | } |
15403 | 15425 | }, |
15404 | 15426 | "deep-extend": { |
... | ... | @@ -15485,7 +15507,7 @@ |
15485 | 15507 | "dev": true, |
15486 | 15508 | "optional": true, |
15487 | 15509 | "requires": { |
15488 | - "minimatch": "3.0.4" | |
15510 | + "minimatch": "^3.0.4" | |
15489 | 15511 | } |
15490 | 15512 | }, |
15491 | 15513 | "inflight": { |
... | ... | @@ -15516,7 +15538,7 @@ |
15516 | 15538 | "dev": true, |
15517 | 15539 | "optional": true, |
15518 | 15540 | "requires": { |
15519 | - "number-is-nan": "1.0.1" | |
15541 | + "number-is-nan": "^1.0.0" | |
15520 | 15542 | } |
15521 | 15543 | }, |
15522 | 15544 | "isarray": { |
... | ... | @@ -15531,7 +15553,7 @@ |
15531 | 15553 | "dev": true, |
15532 | 15554 | "optional": true, |
15533 | 15555 | "requires": { |
15534 | - "brace-expansion": "1.1.11" | |
15556 | + "brace-expansion": "^1.1.7" | |
15535 | 15557 | } |
15536 | 15558 | }, |
15537 | 15559 | "minimist": { |
... | ... | @@ -15609,8 +15631,8 @@ |
15609 | 15631 | "dev": true, |
15610 | 15632 | "optional": true, |
15611 | 15633 | "requires": { |
15612 | - "abbrev": "1.1.1", | |
15613 | - "osenv": "0.1.5" | |
15634 | + "abbrev": "1", | |
15635 | + "osenv": "^0.1.4" | |
15614 | 15636 | } |
15615 | 15637 | }, |
15616 | 15638 | "npm-bundled": { |
... | ... | @@ -15619,7 +15641,7 @@ |
15619 | 15641 | "dev": true, |
15620 | 15642 | "optional": true, |
15621 | 15643 | "requires": { |
15622 | - "npm-normalize-package-bin": "1.0.1" | |
15644 | + "npm-normalize-package-bin": "^1.0.1" | |
15623 | 15645 | } |
15624 | 15646 | }, |
15625 | 15647 | "npm-normalize-package-bin": { |
... | ... | @@ -15634,8 +15656,8 @@ |
15634 | 15656 | "dev": true, |
15635 | 15657 | "optional": true, |
15636 | 15658 | "requires": { |
15637 | - "ignore-walk": "3.0.3", | |
15638 | - "npm-bundled": "1.1.1" | |
15659 | + "ignore-walk": "^3.0.1", | |
15660 | + "npm-bundled": "^1.0.1" | |
15639 | 15661 | } |
15640 | 15662 | }, |
15641 | 15663 | "npmlog": { |
... | ... | @@ -15689,8 +15711,8 @@ |
15689 | 15711 | "dev": true, |
15690 | 15712 | "optional": true, |
15691 | 15713 | "requires": { |
15692 | - "os-homedir": "1.0.2", | |
15693 | - "os-tmpdir": "1.0.2" | |
15714 | + "os-homedir": "^1.0.0", | |
15715 | + "os-tmpdir": "^1.0.0" | |
15694 | 15716 | } |
15695 | 15717 | }, |
15696 | 15718 | "path-is-absolute": { | ... | ... |
... | ... | @@ -58,6 +58,7 @@ |
58 | 58 | "jstree-bootstrap-theme": "^1.0.1", |
59 | 59 | "leaflet": "^1.6.0", |
60 | 60 | "leaflet-geometryutil": "^0.9.3", |
61 | + "leaflet-polylinedecorator": "^1.6.0", | |
61 | 62 | "leaflet-providers": "^1.9.1", |
62 | 63 | "leaflet.gridlayer.googlemutant": "^0.8.0", |
63 | 64 | "leaflet.markercluster": "^1.4.1", |
... | ... | @@ -105,6 +106,7 @@ |
105 | 106 | "@types/js-beautify": "^1.8.1", |
106 | 107 | "@types/jstree": "^3.3.39", |
107 | 108 | "@types/leaflet": "^1.5.9", |
109 | + "@types/leaflet-polylinedecorator": "^1.6.0", | |
108 | 110 | "@types/lodash": "^4.14.149", |
109 | 111 | "@types/raphael": "^2.1.30", |
110 | 112 | "@types/react": "^16.9.20", | ... | ... |
... | ... | @@ -14,8 +14,10 @@ |
14 | 14 | /// limitations under the License. |
15 | 15 | /// |
16 | 16 | |
17 | +import { JsonSchema, JsonSettingsSchema } from '@app/shared/public-api'; | |
17 | 18 | |
18 | -export function initSchema() { | |
19 | + | |
20 | +export function initSchema(): JsonSettingsSchema { | |
19 | 21 | return { |
20 | 22 | schema: { |
21 | 23 | type: 'object', |
... | ... | @@ -27,21 +29,21 @@ export function initSchema() { |
27 | 29 | }; |
28 | 30 | } |
29 | 31 | |
30 | -export function addGroupInfo(schema, title: string) { | |
32 | +export function addGroupInfo(schema: JsonSettingsSchema, title: string) { | |
31 | 33 | schema.groupInfoes.push({ |
32 | 34 | formIndex: schema.groupInfoes?.length || 0, |
33 | 35 | GroupTitle: title |
34 | 36 | }); |
35 | 37 | } |
36 | 38 | |
37 | -export function addToSchema(schema, newSchema) { | |
39 | +export function addToSchema(schema: JsonSettingsSchema, newSchema: JsonSettingsSchema) { | |
38 | 40 | Object.assign(schema.schema.properties, newSchema.schema.properties); |
39 | 41 | schema.schema.required = schema.schema.required.concat(newSchema.schema.required); |
40 | 42 | schema.form.push(newSchema.form); |
41 | 43 | } |
42 | 44 | |
43 | -export function mergeSchemes(schemes: any[]) { | |
44 | - return schemes.reduce((finalSchema, schema) => { | |
45 | +export function mergeSchemes(schemes: JsonSettingsSchema[]): JsonSettingsSchema { | |
46 | + return schemes.reduce((finalSchema: JsonSettingsSchema, schema: JsonSettingsSchema) => { | |
45 | 47 | return { |
46 | 48 | schema: { |
47 | 49 | properties: { |
... | ... | @@ -57,11 +59,11 @@ export function mergeSchemes(schemes: any[]) { |
57 | 59 | ...finalSchema.form, |
58 | 60 | ...schema.form |
59 | 61 | ] |
60 | - } | |
62 | + } as JsonSettingsSchema; | |
61 | 63 | }, initSchema()); |
62 | 64 | } |
63 | 65 | |
64 | -export function addCondition(schema, condition: String) { | |
66 | +export function addCondition(schema: JsonSettingsSchema, condition: String): JsonSettingsSchema { | |
65 | 67 | schema.form = schema.form.map(element => { |
66 | 68 | if (typeof element === 'string') { |
67 | 69 | return { | ... | ... |
... | ... | @@ -529,6 +529,10 @@ export function parseTemplate(template: string, data: object) { |
529 | 529 | .match(/\{(.*?)\}/g) // find expressions |
530 | 530 | .map(exp => exp.replace(/{|}/g, '')) // remove brackets |
531 | 531 | .map(exp => exp.split(':')) |
532 | + .map(arr => { | |
533 | + variables += `let ${arr[0]} = ''; `; | |
534 | + return arr; | |
535 | + }) | |
532 | 536 | .filter(arr => !!arr[1]) // filter expressions without format |
533 | 537 | .reduce((res, current) => { |
534 | 538 | res[current[0]] = current[1]; |
... | ... | @@ -537,7 +541,7 @@ export function parseTemplate(template: string, data: object) { |
537 | 541 | |
538 | 542 | for (const key in data) { |
539 | 543 | if (!key.includes('|')) |
540 | - variables += `let ${key} = '${expressions[key] ? padValue(data[key], +expressions[key]) : data[key]}';`; | |
544 | + variables += `${key} = '${expressions[key] ? padValue(data[key], +expressions[key]) : data[key]}';`; | |
541 | 545 | } |
542 | 546 | template = template.replace(/:\d+}/g, '}'); |
543 | 547 | res = safeExecute(parseFunction(variables + 'return' + '`' + template + '`')); | ... | ... |
... | ... | @@ -15,7 +15,6 @@ |
15 | 15 | /// |
16 | 16 | |
17 | 17 | import L from 'leaflet'; |
18 | -import './add-marker'; | |
19 | 18 | |
20 | 19 | import 'leaflet-providers'; |
21 | 20 | import 'leaflet.markercluster/dist/MarkerCluster.css' |
... | ... | @@ -40,7 +39,7 @@ export default abstract class LeafletMap { |
40 | 39 | map$: BehaviorSubject<L.Map> = new BehaviorSubject(null); |
41 | 40 | ready$: Observable<L.Map> = this.map$.pipe(filter(map => !!map)); |
42 | 41 | options: MapOptions; |
43 | - isMarketCluster; | |
42 | + isMarketCluster: boolean; | |
44 | 43 | bounds: L.LatLngBounds; |
45 | 44 | |
46 | 45 | constructor($container: HTMLElement, options: MapOptions) { |
... | ... | @@ -68,8 +67,8 @@ export default abstract class LeafletMap { |
68 | 67 | |
69 | 68 | addMarkerControl() { |
70 | 69 | if (this.options.draggebleMarker) |
71 | - L.Control.AddMarker = L.Control.extend({ | |
72 | - onAdd (map) { | |
70 | + L.Control.AddMarker = L.Control.extend({ | |
71 | + onAdd(map) { | |
73 | 72 | const img = L.DomUtil.create('img') as any; |
74 | 73 | img.src = `assets/add_location.svg`; |
75 | 74 | img.style.width = '32px'; |
... | ... | @@ -77,10 +76,10 @@ export default abstract class LeafletMap { |
77 | 76 | img.onclick = this.dragMarker; |
78 | 77 | return img; |
79 | 78 | }, |
80 | - addHooks () { | |
79 | + addHooks() { | |
81 | 80 | L.DomEvent.on(window as any, 'onclick', this.enableDragMode, this); |
82 | 81 | }, |
83 | - onRemove (map) { | |
82 | + onRemove(map) { | |
84 | 83 | }, |
85 | 84 | dragMarker: ($event) => { |
86 | 85 | this.dragMode = !this.dragMode; |
... | ... | @@ -122,15 +121,15 @@ export default abstract class LeafletMap { |
122 | 121 | return this.map; |
123 | 122 | } |
124 | 123 | |
125 | - createLatLng(lat, lng) { | |
124 | + createLatLng(lat: number, lng: number): L.LatLng { | |
126 | 125 | return L.latLng(lat, lng); |
127 | 126 | } |
128 | 127 | |
129 | - createBounds() { | |
128 | + createBounds(): L.LatLngBounds { | |
130 | 129 | return this.map.getBounds(); |
131 | 130 | } |
132 | 131 | |
133 | - extendBounds(bounds, polyline) { | |
132 | + extendBounds(bounds: L.LatLngBounds, polyline: L.Polyline) { | |
134 | 133 | if (polyline && polyline.getLatLngs() && polyline.getBounds()) { |
135 | 134 | bounds.extend(polyline.getBounds()); |
136 | 135 | } |
... | ... | @@ -204,7 +203,7 @@ export default abstract class LeafletMap { |
204 | 203 | |
205 | 204 | } |
206 | 205 | |
207 | - // polyline | |
206 | + // Polyline | |
208 | 207 | |
209 | 208 | updatePolylines(polyData: Array<Array<any>>) { |
210 | 209 | polyData.forEach(data => { | ... | ... |
... | ... | @@ -17,7 +17,7 @@ |
17 | 17 | import L from 'leaflet'; |
18 | 18 | import _ from 'lodash'; |
19 | 19 | |
20 | -export function createTooltip(target, settings) { | |
20 | +export function createTooltip(target: L.Layer, settings): L.Popup { | |
21 | 21 | const popup = L.popup(); |
22 | 22 | popup.setContent(''); |
23 | 23 | target.bindPopup(popup, { autoClose: settings.autocloseTooltip, closeOnClick: false }); |
... | ... | @@ -33,3 +33,13 @@ export function createTooltip(target, settings) { |
33 | 33 | return popup; |
34 | 34 | } |
35 | 35 | |
36 | +export function getRatio(firsMoment: number, secondMoment: number, intermediateMoment: number): number { | |
37 | + return (intermediateMoment - firsMoment) / (secondMoment - firsMoment); | |
38 | +}; | |
39 | + | |
40 | +export function findAngle(startPoint, endPoint) { | |
41 | + let angle = -Math.atan2(endPoint.latitude - startPoint.latitude, endPoint.longitude - startPoint.longitude); | |
42 | + angle = angle * 180 / Math.PI; | |
43 | + return parseInt(angle.toFixed(2)); | |
44 | +} | |
45 | + | ... | ... |
... | ... | @@ -14,7 +14,9 @@ |
14 | 14 | /// limitations under the License. |
15 | 15 | /// |
16 | 16 | |
17 | -import L from 'leaflet'; | |
17 | +import L, { PolylineDecoratorOptions } from 'leaflet'; | |
18 | +import 'leaflet-polylinedecorator'; | |
19 | + | |
18 | 20 | import { safeExecute } from '@app/core/utils'; |
19 | 21 | |
20 | 22 | export class Polyline { |
... | ... | @@ -26,9 +28,30 @@ export class Polyline { |
26 | 28 | constructor(private map: L.Map, locations, data, dataSources, settings) { |
27 | 29 | this.dataSources = dataSources; |
28 | 30 | this.data = data; |
31 | + | |
29 | 32 | this.leafletPoly = L.polyline(locations, |
30 | 33 | this.getPolyStyle(settings, data, dataSources) |
31 | 34 | ).addTo(this.map); |
35 | + if (settings.usePolylineDecorator) { | |
36 | + L.polylineDecorator(this.leafletPoly, { | |
37 | + patterns: [ | |
38 | + { | |
39 | + offset: settings.decoratorOffset, | |
40 | + endOffset: settings.endDecoratorOffset, | |
41 | + repeat: settings.decoratorRepeat, | |
42 | + symbol: L.Symbol[settings.decoratorSymbol]({ | |
43 | + pixelSize: settings.decoratorSymbolSize, | |
44 | + polygon: false, | |
45 | + pathOptions: { | |
46 | + color: settings.useDecoratorCustomColor ? settings.decoratorCustomColor : this.getPolyStyle(settings, data, dataSources).color, | |
47 | + stroke: true | |
48 | + } | |
49 | + }) | |
50 | + } | |
51 | + ], | |
52 | + interactive: false, | |
53 | + } as PolylineDecoratorOptions).addTo(this.map); | |
54 | + } | |
32 | 55 | } |
33 | 56 | |
34 | 57 | updatePolyline(settings, data, dataSources) { |
... | ... | @@ -38,8 +61,8 @@ export class Polyline { |
38 | 61 | getPolyStyle(settings, data, dataSources): L.PolylineOptions { |
39 | 62 | return { |
40 | 63 | color: settings.useColorFunction ? safeExecute(settings.colorFunction, [data, dataSources, data[0]?.dsIndex]) : settings.color, |
41 | - opacity: settings.strokeOpacity, | |
42 | - weight: settings.strokeWeight | |
64 | + opacity: settings.useStrokeOpacityFunction ? safeExecute(settings.strokeOpacityFunction, [data, dataSources, data[0]?.dsIndex]) : settings.strokeOpacity, | |
65 | + weight: settings.useStrokeWeightFunction ? safeExecute(settings.strokeWeightFunction, [data, dataSources, data[0]?.dsIndex]) : settings.strokeWeight, | |
43 | 66 | } |
44 | 67 | } |
45 | 68 | ... | ... |
... | ... | @@ -26,8 +26,9 @@ import { parseArray, parseTemplate, safeExecute } from '@app/core/utils'; |
26 | 26 | import { initSchema, addToSchema, addGroupInfo } from '@app/core/schema-utils'; |
27 | 27 | import { tripAnimationSchema } from '../lib/maps/schemes'; |
28 | 28 | import { DomSanitizer } from '@angular/platform-browser'; |
29 | -import { WidgetConfig } from '@app/shared/public-api'; | |
29 | +import { WidgetConfig, JsonSchema, JsonSettingsSchema } from '@app/shared/public-api'; | |
30 | 30 | import { WidgetContext } from '@app/modules/home/models/widget-component.models'; |
31 | +import { getRatio, findAngle } from '../lib/maps/maps-utils'; | |
31 | 32 | |
32 | 33 | |
33 | 34 | @Component({ |
... | ... | @@ -37,7 +38,7 @@ import { WidgetContext } from '@app/modules/home/models/widget-component.models' |
37 | 38 | }) |
38 | 39 | export class TripAnimationComponent implements OnInit, AfterViewInit { |
39 | 40 | |
40 | - constructor(private cd: ChangeDetectorRef,private sanitizer: DomSanitizer) { } | |
41 | + constructor(private cd: ChangeDetectorRef, private sanitizer: DomSanitizer) { } | |
41 | 42 | |
42 | 43 | @Input() ctx: WidgetContext; |
43 | 44 | |
... | ... | @@ -48,13 +49,13 @@ export class TripAnimationComponent implements OnInit, AfterViewInit { |
48 | 49 | intervals; |
49 | 50 | normalizationStep = 1000; |
50 | 51 | interpolatedData = []; |
51 | - widgetConfig; | |
52 | + widgetConfig: WidgetConfig; | |
52 | 53 | settings; |
53 | 54 | mainTooltip = ''; |
54 | 55 | visibleTooltip = false; |
55 | 56 | activeTrip; |
56 | 57 | |
57 | - static getSettingsSchema() { | |
58 | + static getSettingsSchema(): JsonSettingsSchema { | |
58 | 59 | const schema = initSchema(); |
59 | 60 | addToSchema(schema, TbMapWidgetV2.getProvidersSchema()); |
60 | 61 | addGroupInfo(schema, 'Map Provider Settings'); |
... | ... | @@ -79,6 +80,8 @@ export class TripAnimationComponent implements OnInit, AfterViewInit { |
79 | 80 | this.activeTrip = this.historicalData[0][0]; |
80 | 81 | this.calculateIntervals(); |
81 | 82 | this.timeUpdated(this.intervals[0]); |
83 | + this.mapWidget.map.updatePolylines(this.interpolatedData.map(ds => _.values(ds))); | |
84 | + | |
82 | 85 | this.mapWidget.map.map?.invalidateSize(); |
83 | 86 | this.cd.detectChanges(); |
84 | 87 | } |
... | ... | @@ -91,16 +94,20 @@ export class TripAnimationComponent implements OnInit, AfterViewInit { |
91 | 94 | this.mapWidget = new MapWidgetController(MapProviders.openstreet, false, ctxCopy, this.mapContainer.nativeElement); |
92 | 95 | } |
93 | 96 | |
94 | - timeUpdated(time) { | |
97 | + timeUpdated(time: number) { | |
95 | 98 | const currentPosition = this.interpolatedData.map(dataSource => dataSource[time]); |
96 | 99 | this.activeTrip = currentPosition[0]; |
97 | - this.mapWidget.map.updatePolylines(this.interpolatedData); | |
100 | + console.log("TripAnimationComponent -> timeUpdated -> this.interpolatedData", this.interpolatedData) | |
98 | 101 | if (this.settings.showPolygon) { |
99 | 102 | this.mapWidget.map.updatePolygons(this.interpolatedData); |
100 | 103 | } |
101 | 104 | this.mapWidget.map.updateMarkers(currentPosition); |
102 | 105 | } |
103 | 106 | |
107 | + setActiveTrip() { | |
108 | + | |
109 | + } | |
110 | + | |
104 | 111 | calculateIntervals() { |
105 | 112 | this.historicalData.forEach((dataSource, index) => { |
106 | 113 | this.intervals = []; |
... | ... | @@ -113,24 +120,16 @@ export class TripAnimationComponent implements OnInit, AfterViewInit { |
113 | 120 | } |
114 | 121 | |
115 | 122 | showHideTooltip() { |
116 | - console.log(this.activeTrip); | |
117 | - const tooltipText: string = this.settings.useTooltipFunction ? safeExecute(this.settings.tooolTipFunction) : | |
118 | - // this.mainTooltip = this.sanitizer.sanitize(SecurityContext.HTML, parseTemplate(tooltipText, this.activeTrip)) | |
119 | - this.visibleTooltip = !this.visibleTooltip; | |
123 | + const tooltipText: string = this.settings.useTooltipFunction ? safeExecute(this.settings.tooolTipFunction, [this.activeTrip, this.historicalData, 0]) | |
124 | + : this.settings.tooltipPattern; | |
125 | + | |
126 | + this.mainTooltip = this.sanitizer.sanitize(SecurityContext.HTML, parseTemplate(tooltipText, this.activeTrip)) | |
127 | + console.log("TripAnimationComponent -> showHideTooltip -> this.mainTooltip", this.mainTooltip) | |
128 | + this.visibleTooltip = !this.visibleTooltip; | |
120 | 129 | } |
121 | 130 | |
122 | 131 | interpolateArray(originData, interpolatedIntervals) { |
123 | 132 | |
124 | - const getRatio = (firsMoment, secondMoment, intermediateMoment) => { | |
125 | - return (intermediateMoment - firsMoment) / (secondMoment - firsMoment); | |
126 | - }; | |
127 | - | |
128 | - function findAngle(startPoint, endPoint) { | |
129 | - let angle = -Math.atan2(endPoint.latitude - startPoint.latitude, endPoint.longitude - startPoint.longitude); | |
130 | - angle = angle * 180 / Math.PI; | |
131 | - return parseInt(angle.toFixed(2)); | |
132 | - } | |
133 | - | |
134 | 133 | const result = {}; |
135 | 134 | |
136 | 135 | for (let i = 1, j = 0; i < originData.length, j < interpolatedIntervals.length;) { |
... | ... | @@ -151,6 +150,8 @@ export class TripAnimationComponent implements OnInit, AfterViewInit { |
151 | 150 | j++; |
152 | 151 | } |
153 | 152 | return result; |
154 | - }} | |
153 | + } | |
154 | +} | |
155 | + | |
156 | +export let TbTripAnimationWidget = TripAnimationComponent; | |
155 | 157 | |
156 | -export let TbTripAnimationWidget = TripAnimationComponent; | |
\ No newline at end of file | ... | ... |
... | ... | @@ -15,7 +15,7 @@ |
15 | 15 | /// |
16 | 16 | |
17 | 17 | import { Component, OnInit, OnChanges, Input, Output, EventEmitter, ChangeDetectorRef } from '@angular/core'; |
18 | -import { interval, Subscription } from 'rxjs'; | |
18 | +import { interval, Subscription, Subscriber, SubscriptionLike, Observer } from 'rxjs'; | |
19 | 19 | import { filter, tap } from 'rxjs/operators'; |
20 | 20 | |
21 | 21 | @Component({ |
... | ... | @@ -28,7 +28,7 @@ export class HistorySelectorComponent implements OnInit, OnChanges { |
28 | 28 | @Input() settings |
29 | 29 | @Input() intervals = []; |
30 | 30 | |
31 | - @Output() onTimeUpdated = new EventEmitter(); | |
31 | + @Output() onTimeUpdated: EventEmitter<number> = new EventEmitter(); | |
32 | 32 | |
33 | 33 | animationTime; |
34 | 34 | minTimeIndex = 0; |
... | ... | @@ -70,12 +70,14 @@ export class HistorySelectorComponent implements OnInit, OnChanges { |
70 | 70 | this.playing = false; |
71 | 71 | this.interval = null; |
72 | 72 | this.cd.detectChanges(); |
73 | - }); | |
73 | + }); | |
74 | 74 | } |
75 | 75 | |
76 | 76 | reeneble() { |
77 | 77 | if (this.playing) { |
78 | + let position = this.index; | |
78 | 79 | this.interval.complete(); |
80 | + this.index = position; | |
79 | 81 | this.play(); |
80 | 82 | } |
81 | 83 | } | ... | ... |
ui-ngx/src/typings/add-marker.d.ts
renamed from
ui-ngx/src/app/modules/home/components/widget/lib/maps/add-marker.ts
... | ... | @@ -19,7 +19,8 @@ |
19 | 19 | "src/typings/jquery.typings.d.ts", |
20 | 20 | "src/typings/jquery.flot.typings.d.ts", |
21 | 21 | "src/typings/jquery.jstree.typings.d.ts", |
22 | - "src/typings/split.js.typings.d.ts" | |
22 | + "src/typings/split.js.typings.d.ts", | |
23 | + "src/typings/add-marker.d.ts" | |
23 | 24 | ], |
24 | 25 | "paths": { |
25 | 26 | "@app/*": ["src/app/*"], | ... | ... |