1 | import { a as __extends } from './tslib.es6-f952ba6f.js';
|
2 | import { S as ServerClient } from './ServerClient-8d9a15d8.js';
|
3 | import { H as HistoryPlayback } from './HistoryPlayback-ce40ad04.js';
|
4 | import { Map, AuthenticationType, source, Popup, HtmlMarker } from 'azure-maps-control';
|
5 |
|
6 | var GeoProcessGraphic = (function (_super) {
|
7 | __extends(GeoProcessGraphic, _super);
|
8 | function GeoProcessGraphic(renderTarget) {
|
9 | var _this = _super.call(this, renderTarget) || this;
|
10 | _this.serverClient = new ServerClient();
|
11 | _this.currentCancelTrigger = null;
|
12 | return _this;
|
13 | }
|
14 | GeoProcessGraphic.prototype.render = function (environmentFqdn, getToken, data, chartOptions) {
|
15 | this.zoom = chartOptions.zoom;
|
16 | this.center = chartOptions.center;
|
17 | this.bearing = chartOptions.bearing;
|
18 | this.pitch = chartOptions.pitch;
|
19 | this.maxZoom = chartOptions.maxZoom;
|
20 | this.minZoom = chartOptions.minZoom;
|
21 | this.duration = chartOptions.duration;
|
22 | this.azureMapsSubscriptionKey = chartOptions.subscriptionKey;
|
23 | this.width = chartOptions.width;
|
24 | this.height = chartOptions.height;
|
25 | this.theme = chartOptions.theme;
|
26 | this.renderBase(environmentFqdn, getToken, data, chartOptions);
|
27 | };
|
28 | GeoProcessGraphic.prototype.loadResources = function () {
|
29 | var _this = this;
|
30 | this.component.node().style.width = this.width + "px";
|
31 | this.component.node().style.height = this.height + "px";
|
32 | this.map = new Map(this.component.node(), {
|
33 | authOptions: {
|
34 | authType: AuthenticationType.subscriptionKey,
|
35 | subscriptionKey: this.azureMapsSubscriptionKey
|
36 | }
|
37 | });
|
38 | this.map.events.add('ready', function () {
|
39 | _this.dataSource = new source.DataSource();
|
40 | _this.map.sources.add(_this.dataSource);
|
41 | var _loop_1 = function (i) {
|
42 | var popup = new Popup({
|
43 | content: "<div class = 'tsi-gpgPopUp id= tsi-popup" + i + "'></div>",
|
44 | pixelOffset: [0, -30]
|
45 | });
|
46 | var marker = new HtmlMarker({
|
47 | htmlContent: "<div class = tsi-geoprocess-graphic> <img class='tsi-gpgcircleImage \n id= tsi-htmlMarker" + i + "' src= \"" + _this.tsqExpressions[i].image + '" /> </div>',
|
48 | position: [0, 0],
|
49 | popup: popup
|
50 | });
|
51 | _this.map.markers.add(marker);
|
52 | _this.map.popups.add(popup);
|
53 | _this.map.events.add('click', marker, function () {
|
54 | marker.togglePopup();
|
55 | });
|
56 | };
|
57 | for (var i = 0; i < _this.tsqExpressions.length; i++) {
|
58 | _loop_1(i);
|
59 | }
|
60 | });
|
61 | this.map.setCamera({
|
62 | center: this.center,
|
63 | bearing: this.bearing,
|
64 | pitch: this.pitch,
|
65 | zoom: this.zoom,
|
66 | maxZoom: this.maxZoom,
|
67 | minZoom: this.minZoom,
|
68 | type: "fly",
|
69 | duration: this.duration
|
70 | });
|
71 | return Promise.resolve();
|
72 | };
|
73 | GeoProcessGraphic.prototype.draw = function () {
|
74 | this.drawBase();
|
75 | };
|
76 | GeoProcessGraphic.prototype.getDataPoints = function (results) {
|
77 | var _this = this;
|
78 | var dataPoints = results.map(function (r) {
|
79 | return _this.parseTsqResponse(r);
|
80 | });
|
81 | this.updateDataMarkers(dataPoints);
|
82 | };
|
83 | GeoProcessGraphic.prototype.parseTsqResponse = function (response) {
|
84 | var parsedResponse = {};
|
85 | if (response && response.properties) {
|
86 | for (var i = 0; i < response.properties.length; i++) {
|
87 | response.properties[i] && response.properties[i].name && response.properties[i].values ?
|
88 | parsedResponse[response.properties[i].name] = response.properties[i].values[0]
|
89 | : null;
|
90 | }
|
91 | }
|
92 | return parsedResponse;
|
93 | };
|
94 | GeoProcessGraphic.prototype.updateDataMarkers = function (dataPoints) {
|
95 | for (var i = 0; i < dataPoints.length; i++) {
|
96 | var lat = dataPoints[i][this.tsqExpressions[i].positionXVariableName];
|
97 | var lon = dataPoints[i][this.tsqExpressions[i].positionYVariableName];
|
98 | this.map.markers.getMarkers()[i].setOptions({
|
99 | position: [lat, lon]
|
100 | });
|
101 | var dataPointArr = Object.entries(dataPoints[i]);
|
102 | this.map.popups.getPopups()[i].setOptions({
|
103 | position: [lat, lon],
|
104 | content: this.createTable(dataPointArr, i)
|
105 | });
|
106 | }
|
107 | };
|
108 | GeoProcessGraphic.prototype.createTable = function (dataPointArr, idx) {
|
109 | var gpgTooltipDiv = document.createElement('div');
|
110 | gpgTooltipDiv.className = 'tsi-gpgTooltip tsi-' + this.theme;
|
111 | var gpgTooltipInnerDiv = document.createElement('div');
|
112 | gpgTooltipInnerDiv.className = 'tsi-gpgTooltipInner';
|
113 | var gpgTooltipTitleDiv = document.createElement('div');
|
114 | gpgTooltipTitleDiv.className = 'tsi-gpgTooltipTitle';
|
115 | var title = document.createTextNode(this.tsqExpressions[idx].alias);
|
116 | gpgTooltipTitleDiv.appendChild(title);
|
117 | var gpgTooltipTable = document.createElement('table');
|
118 | gpgTooltipTable.className = 'tsi-gpgTooltipValues';
|
119 | gpgTooltipTable.classList.add('tsi-gpgTooltipTable');
|
120 | for (var i = 0; i < dataPointArr.length; i++) {
|
121 | var spacer = document.createElement('tr');
|
122 | spacer.className = 'tsi-gpgTableSpacer';
|
123 | gpgTooltipTable.appendChild(spacer);
|
124 | var gpgTooltipValueRow = document.createElement('tr');
|
125 | var gpgValueLabelCell = document.createElement('td');
|
126 | gpgValueLabelCell.className = 'tsi-gpgValueLabel';
|
127 | var labelName = document.createTextNode(dataPointArr[i][0]);
|
128 | gpgValueLabelCell.appendChild(labelName);
|
129 | gpgTooltipValueRow.appendChild(gpgValueLabelCell);
|
130 | var gpgValueCell = document.createElement('td');
|
131 | gpgValueCell.className = 'tsi-gpgValueCell';
|
132 | var cellData = document.createTextNode(dataPointArr[i][1].toFixed(5));
|
133 | gpgValueCell.appendChild(cellData);
|
134 | gpgTooltipValueRow.appendChild(gpgValueCell);
|
135 | gpgTooltipTable.appendChild(gpgTooltipValueRow);
|
136 | }
|
137 | gpgTooltipInnerDiv.appendChild(gpgTooltipTitleDiv);
|
138 | gpgTooltipInnerDiv.appendChild(gpgTooltipTable);
|
139 | gpgTooltipDiv.appendChild(gpgTooltipInnerDiv);
|
140 | return gpgTooltipDiv;
|
141 | };
|
142 | return GeoProcessGraphic;
|
143 | }(HistoryPlayback));
|
144 |
|
145 | export { GeoProcessGraphic as G };
|