@dssp/dkpi 1.0.0-alpha.58 → 1.0.0-alpha.59
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/dist-client/components/kpi-boxplot-chart.d.ts +1 -1
- package/dist-client/components/kpi-boxplot-chart.js +17 -17
- package/dist-client/components/kpi-boxplot-chart.js.map +1 -1
- package/dist-client/components/kpi-lookup-chart.d.ts +29 -0
- package/dist-client/components/kpi-lookup-chart.js +434 -0
- package/dist-client/components/kpi-lookup-chart.js.map +1 -0
- package/dist-client/components/kpi-mini-trend-chart.d.ts +14 -0
- package/dist-client/components/kpi-mini-trend-chart.js +148 -0
- package/dist-client/components/kpi-mini-trend-chart.js.map +1 -0
- package/dist-client/components/kpi-radar-chart.d.ts +1 -1
- package/dist-client/components/kpi-radar-chart.js +73 -55
- package/dist-client/components/kpi-radar-chart.js.map +1 -1
- package/dist-client/components/kpi-trend-chart.d.ts +25 -0
- package/dist-client/components/kpi-trend-chart.js +220 -0
- package/dist-client/components/kpi-trend-chart.js.map +1 -0
- package/dist-client/google-map/common-google-map.d.ts +35 -0
- package/dist-client/google-map/common-google-map.js +343 -0
- package/dist-client/google-map/common-google-map.js.map +1 -0
- package/dist-client/google-map/google-map-loader.d.ts +6 -0
- package/dist-client/google-map/google-map-loader.js +23 -0
- package/dist-client/google-map/google-map-loader.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level1-card.d.ts +17 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level1-card.js +280 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level1-card.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level2-comparison.d.ts +21 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level2-comparison.js +389 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level2-comparison.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level3-comparison.d.ts +25 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level3-comparison.js +469 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level3-comparison.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-chart-toggle.d.ts +8 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-chart-toggle.js +78 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-chart-toggle.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-left-panel.d.ts +34 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-left-panel.js +642 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-left-panel.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-map-panel.d.ts +38 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-map-panel.js +501 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-map-panel.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-region-popup.d.ts +26 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-region-popup.js +439 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-region-popup.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-alert-panel.d.ts +18 -0
- package/dist-client/pages/kpi-dashboard/kpi-alert-panel.js +131 -0
- package/dist-client/pages/kpi-dashboard/kpi-alert-panel.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-dashboard-map.d.ts +36 -0
- package/dist-client/pages/kpi-dashboard/kpi-dashboard-map.js +572 -0
- package/dist-client/pages/kpi-dashboard/kpi-dashboard-map.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-dashboard.d.ts +59 -0
- package/dist-client/pages/kpi-dashboard/kpi-dashboard.js +1027 -0
- package/dist-client/pages/kpi-dashboard/kpi-dashboard.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-grade-visualization.d.ts +12 -0
- package/dist-client/pages/kpi-dashboard/kpi-grade-visualization.js +82 -0
- package/dist-client/pages/kpi-dashboard/kpi-grade-visualization.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-history-viewer.d.ts +11 -0
- package/dist-client/pages/kpi-dashboard/kpi-history-viewer.js +65 -0
- package/dist-client/pages/kpi-dashboard/kpi-history-viewer.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-list-summary.d.ts +13 -0
- package/dist-client/pages/kpi-dashboard/kpi-list-summary.js +115 -0
- package/dist-client/pages/kpi-dashboard/kpi-list-summary.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-performance-summary.d.ts +15 -0
- package/dist-client/pages/kpi-dashboard/kpi-performance-summary.js +147 -0
- package/dist-client/pages/kpi-dashboard/kpi-performance-summary.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-value-entry.d.ts +7 -0
- package/dist-client/pages/kpi-dashboard/kpi-value-entry.js +86 -0
- package/dist-client/pages/kpi-dashboard/kpi-value-entry.js.map +1 -0
- package/dist-client/pages/sv-project-detail.d.ts +6 -0
- package/dist-client/pages/sv-project-detail.js +170 -10
- package/dist-client/pages/sv-project-detail.js.map +1 -1
- package/dist-client/route.d.ts +1 -1
- package/dist-client/route.js +3 -0
- package/dist-client/route.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.d.ts +16 -0
- package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.js +132 -16
- package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.js.map +1 -1
- package/dist-server/service/kpi-stat/kpi-stat-query.d.ts +6 -4
- package/dist-server/service/kpi-stat/kpi-stat-query.js +232 -22
- package/dist-server/service/kpi-stat/kpi-stat-query.js.map +1 -1
- package/dist-server/service/kpi-stat/kpi-stat-types.d.ts +6 -0
- package/dist-server/service/kpi-stat/kpi-stat-types.js +23 -1
- package/dist-server/service/kpi-stat/kpi-stat-types.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { LitElement, html, css } from 'lit';
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import * as d3 from 'd3';
|
|
5
|
+
let SvKpiTrendChart = class SvKpiTrendChart extends LitElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.data = [];
|
|
9
|
+
this.valueKey = 'value';
|
|
10
|
+
this.dateKey = 'date';
|
|
11
|
+
this.width = 400;
|
|
12
|
+
this.height = 200;
|
|
13
|
+
this.lineColor = '#2196f3';
|
|
14
|
+
this.strokeWidth = 2;
|
|
15
|
+
this.showPoints = true;
|
|
16
|
+
this.pointRadius = 4;
|
|
17
|
+
this.chartWidth = 0;
|
|
18
|
+
this.chartHeight = 0;
|
|
19
|
+
}
|
|
20
|
+
render() {
|
|
21
|
+
return html `
|
|
22
|
+
<div class="chart-container">
|
|
23
|
+
<svg
|
|
24
|
+
id="trend-chart"
|
|
25
|
+
width=${this.chartWidth || this.width}
|
|
26
|
+
height=${this.chartHeight || this.height}
|
|
27
|
+
viewBox="0 0 ${this.chartWidth || this.width} ${this.chartHeight || this.height}"
|
|
28
|
+
preserveAspectRatio="xMidYMid meet"
|
|
29
|
+
></svg>
|
|
30
|
+
</div>
|
|
31
|
+
`;
|
|
32
|
+
}
|
|
33
|
+
connectedCallback() {
|
|
34
|
+
super.connectedCallback();
|
|
35
|
+
this.resizeObserver = new ResizeObserver(entries => {
|
|
36
|
+
for (const entry of entries) {
|
|
37
|
+
const rect = entry.contentRect;
|
|
38
|
+
this.chartWidth = rect.width;
|
|
39
|
+
this.chartHeight = rect.height;
|
|
40
|
+
this.requestUpdate();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
this.resizeObserver.observe(this);
|
|
44
|
+
}
|
|
45
|
+
disconnectedCallback() {
|
|
46
|
+
var _a;
|
|
47
|
+
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
48
|
+
super.disconnectedCallback();
|
|
49
|
+
}
|
|
50
|
+
updated() {
|
|
51
|
+
this.drawTrendChart();
|
|
52
|
+
}
|
|
53
|
+
drawTrendChart() {
|
|
54
|
+
if (!this.data || this.data.length === 0)
|
|
55
|
+
return;
|
|
56
|
+
const svg = d3.select(this.renderRoot.querySelector('#trend-chart'));
|
|
57
|
+
svg.selectAll('*').remove();
|
|
58
|
+
const margin = { top: 20, right: 20, bottom: 50, left: 40 };
|
|
59
|
+
const width = this.chartWidth || this.width;
|
|
60
|
+
const height = this.chartHeight || this.height;
|
|
61
|
+
const chartWidth = width - margin.left - margin.right;
|
|
62
|
+
const chartHeight = height - margin.top - margin.bottom;
|
|
63
|
+
// 데이터 파싱
|
|
64
|
+
const parsedData = this.data.map(d => ({
|
|
65
|
+
date: new Date(d[this.dateKey]),
|
|
66
|
+
value: +d[this.valueKey],
|
|
67
|
+
color: d.color || this.lineColor
|
|
68
|
+
}));
|
|
69
|
+
// 스케일 설정
|
|
70
|
+
const xScale = d3
|
|
71
|
+
.scaleTime()
|
|
72
|
+
.domain(d3.extent(parsedData, d => d.date))
|
|
73
|
+
.range([0, chartWidth]);
|
|
74
|
+
const yScale = d3
|
|
75
|
+
.scaleLinear()
|
|
76
|
+
.domain([0, d3.max(parsedData, d => d.value) || 100])
|
|
77
|
+
.range([chartHeight, 0]);
|
|
78
|
+
// SVG 설정
|
|
79
|
+
svg.attr('width', width).attr('height', height);
|
|
80
|
+
const g = svg.append('g').attr('transform', `translate(${margin.left},${margin.top})`);
|
|
81
|
+
// 축 생성 - 연도가 바뀌면 연도 포함
|
|
82
|
+
const timeFormat = (date) => {
|
|
83
|
+
const dates = parsedData.map(d => d.date);
|
|
84
|
+
const years = [...new Set(dates.map(d => d.getFullYear()))];
|
|
85
|
+
// 여러 연도가 있으면 연도 포함
|
|
86
|
+
if (years.length > 1) {
|
|
87
|
+
return d3.timeFormat('%Y-%m')(date);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
return d3.timeFormat('%m/%d')(date);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const xAxis = d3.axisBottom(xScale).tickFormat(timeFormat).ticks(Math.min(parsedData.length, 10));
|
|
94
|
+
const yAxis = d3.axisLeft(yScale).ticks(5);
|
|
95
|
+
// X축 그리드 라인 추가
|
|
96
|
+
g.append('g')
|
|
97
|
+
.attr('class', 'grid')
|
|
98
|
+
.attr('transform', `translate(0,${chartHeight})`)
|
|
99
|
+
.call(d3
|
|
100
|
+
.axisBottom(xScale)
|
|
101
|
+
.ticks(Math.min(parsedData.length, 10))
|
|
102
|
+
.tickSize(-chartHeight)
|
|
103
|
+
.tickFormat(() => ''));
|
|
104
|
+
g.append('g')
|
|
105
|
+
.attr('class', 'axis')
|
|
106
|
+
.attr('transform', `translate(0,${chartHeight})`)
|
|
107
|
+
.call(xAxis)
|
|
108
|
+
.selectAll('text')
|
|
109
|
+
.style('text-anchor', 'end')
|
|
110
|
+
.attr('dx', '-.5em')
|
|
111
|
+
.attr('dy', '.3em')
|
|
112
|
+
.attr('transform', 'rotate(-30)');
|
|
113
|
+
g.append('g').attr('class', 'axis').call(yAxis);
|
|
114
|
+
// 라인 생성기
|
|
115
|
+
const line = d3
|
|
116
|
+
.line()
|
|
117
|
+
.x(d => xScale(d.date))
|
|
118
|
+
.y(d => yScale(d.value))
|
|
119
|
+
.curve(d3.curveMonotoneX);
|
|
120
|
+
// 트렌드 라인 그리기
|
|
121
|
+
g.append('path')
|
|
122
|
+
.datum(parsedData)
|
|
123
|
+
.attr('class', 'trend-line')
|
|
124
|
+
.attr('d', line)
|
|
125
|
+
.attr('stroke', this.lineColor)
|
|
126
|
+
.attr('stroke-width', this.strokeWidth);
|
|
127
|
+
// 데이터 포인트 그리기
|
|
128
|
+
if (this.showPoints) {
|
|
129
|
+
g.selectAll('.data-point')
|
|
130
|
+
.data(parsedData)
|
|
131
|
+
.enter()
|
|
132
|
+
.append('circle')
|
|
133
|
+
.attr('class', 'data-point')
|
|
134
|
+
.attr('cx', d => xScale(d.date))
|
|
135
|
+
.attr('cy', d => yScale(d.value))
|
|
136
|
+
.attr('r', this.pointRadius)
|
|
137
|
+
.attr('stroke', d => d.color)
|
|
138
|
+
.attr('fill', 'white');
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
SvKpiTrendChart.styles = css `
|
|
143
|
+
:host {
|
|
144
|
+
display: block;
|
|
145
|
+
width: 100%;
|
|
146
|
+
height: 100%;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.chart-container {
|
|
150
|
+
width: 100%;
|
|
151
|
+
height: 100%;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.trend-line {
|
|
155
|
+
fill: none;
|
|
156
|
+
stroke-linecap: round;
|
|
157
|
+
stroke-linejoin: round;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.data-point {
|
|
161
|
+
fill: white;
|
|
162
|
+
stroke-width: 2;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.axis line,
|
|
166
|
+
.axis path,
|
|
167
|
+
.grid line {
|
|
168
|
+
stroke: #ddd;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.grid path {
|
|
172
|
+
stroke: none;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.axis text {
|
|
176
|
+
font-size: 10px;
|
|
177
|
+
fill: #666;
|
|
178
|
+
}
|
|
179
|
+
`;
|
|
180
|
+
__decorate([
|
|
181
|
+
property({ type: Array }),
|
|
182
|
+
__metadata("design:type", Array)
|
|
183
|
+
], SvKpiTrendChart.prototype, "data", void 0);
|
|
184
|
+
__decorate([
|
|
185
|
+
property({ type: String }),
|
|
186
|
+
__metadata("design:type", String)
|
|
187
|
+
], SvKpiTrendChart.prototype, "valueKey", void 0);
|
|
188
|
+
__decorate([
|
|
189
|
+
property({ type: String }),
|
|
190
|
+
__metadata("design:type", String)
|
|
191
|
+
], SvKpiTrendChart.prototype, "dateKey", void 0);
|
|
192
|
+
__decorate([
|
|
193
|
+
property({ type: Number }),
|
|
194
|
+
__metadata("design:type", Number)
|
|
195
|
+
], SvKpiTrendChart.prototype, "width", void 0);
|
|
196
|
+
__decorate([
|
|
197
|
+
property({ type: Number }),
|
|
198
|
+
__metadata("design:type", Number)
|
|
199
|
+
], SvKpiTrendChart.prototype, "height", void 0);
|
|
200
|
+
__decorate([
|
|
201
|
+
property({ type: String }),
|
|
202
|
+
__metadata("design:type", String)
|
|
203
|
+
], SvKpiTrendChart.prototype, "lineColor", void 0);
|
|
204
|
+
__decorate([
|
|
205
|
+
property({ type: Number }),
|
|
206
|
+
__metadata("design:type", Number)
|
|
207
|
+
], SvKpiTrendChart.prototype, "strokeWidth", void 0);
|
|
208
|
+
__decorate([
|
|
209
|
+
property({ type: Boolean }),
|
|
210
|
+
__metadata("design:type", Boolean)
|
|
211
|
+
], SvKpiTrendChart.prototype, "showPoints", void 0);
|
|
212
|
+
__decorate([
|
|
213
|
+
property({ type: Number }),
|
|
214
|
+
__metadata("design:type", Number)
|
|
215
|
+
], SvKpiTrendChart.prototype, "pointRadius", void 0);
|
|
216
|
+
SvKpiTrendChart = __decorate([
|
|
217
|
+
customElement('sv-kpi-trend-chart')
|
|
218
|
+
], SvKpiTrendChart);
|
|
219
|
+
export { SvKpiTrendChart };
|
|
220
|
+
//# sourceMappingURL=kpi-trend-chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kpi-trend-chart.js","sourceRoot":"","sources":["../../client/components/kpi-trend-chart.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AAGjB,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,UAAU;IAAxC;;QACsB,SAAI,GAAsD,EAAE,CA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A6D;AAC3D;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;iDAA2B;AAC1B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDAAyB;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;8CAAoB;AACnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;+CAAqB;AACpB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAA8B;AAC7B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDAAwB;AACtB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;mDAA2B;AAC3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDAAwB;AATxC,eAAe;IAD3B,aAAa,CAAC,oBAAoB,CAAC;GACvB,eAAe,CAkM3B","sourcesContent":["import { LitElement, html, css } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport * as d3 from 'd3'\n\n@customElement('sv-kpi-trend-chart')\nexport class SvKpiTrendChart extends LitElement {\n @property({ type: Array }) data: { date: string; value: number; color?: string }[] = []\n @property({ type: String }) valueKey: string = 'value'\n @property({ type: String }) dateKey: string = 'date'\n @property({ type: Number }) width: number = 400\n @property({ type: Number }) height: number = 200\n @property({ type: String }) lineColor: string = '#2196f3'\n @property({ type: Number }) strokeWidth: number = 2\n @property({ type: Boolean }) showPoints: boolean = true\n @property({ type: Number }) pointRadius: number = 4\n\n private chartWidth = 0\n private chartHeight = 0\n private resizeObserver?: ResizeObserver\n\n static styles = css`\n :host {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n .chart-container {\n width: 100%;\n height: 100%;\n }\n\n .trend-line {\n fill: none;\n stroke-linecap: round;\n stroke-linejoin: round;\n }\n\n .data-point {\n fill: white;\n stroke-width: 2;\n }\n\n .axis line,\n .axis path,\n .grid line {\n stroke: #ddd;\n }\n\n .grid path {\n stroke: none;\n }\n\n .axis text {\n font-size: 10px;\n fill: #666;\n }\n `\n\n render() {\n return html`\n <div class=\"chart-container\">\n <svg\n id=\"trend-chart\"\n width=${this.chartWidth || this.width}\n height=${this.chartHeight || this.height}\n viewBox=\"0 0 ${this.chartWidth || this.width} ${this.chartHeight || this.height}\"\n preserveAspectRatio=\"xMidYMid meet\"\n ></svg>\n </div>\n `\n }\n\n connectedCallback() {\n super.connectedCallback()\n this.resizeObserver = new ResizeObserver(entries => {\n for (const entry of entries) {\n const rect = entry.contentRect\n this.chartWidth = rect.width\n this.chartHeight = rect.height\n this.requestUpdate()\n }\n })\n this.resizeObserver.observe(this)\n }\n\n disconnectedCallback() {\n this.resizeObserver?.disconnect()\n super.disconnectedCallback()\n }\n\n updated() {\n this.drawTrendChart()\n }\n\n drawTrendChart() {\n if (!this.data || this.data.length === 0) return\n\n const svg = d3.select(this.renderRoot.querySelector('#trend-chart'))\n svg.selectAll('*').remove()\n\n const margin = { top: 20, right: 20, bottom: 50, left: 40 }\n const width = this.chartWidth || this.width\n const height = this.chartHeight || this.height\n const chartWidth = width - margin.left - margin.right\n const chartHeight = height - margin.top - margin.bottom\n\n // 데이터 파싱\n const parsedData = this.data.map(d => ({\n date: new Date(d[this.dateKey]),\n value: +d[this.valueKey],\n color: d.color || this.lineColor\n }))\n\n // 스케일 설정\n const xScale = d3\n .scaleTime()\n .domain(d3.extent(parsedData, d => d.date) as [Date, Date])\n .range([0, chartWidth])\n\n const yScale = d3\n .scaleLinear()\n .domain([0, d3.max(parsedData, d => d.value) || 100])\n .range([chartHeight, 0])\n\n // SVG 설정\n svg.attr('width', width).attr('height', height)\n const g = svg.append('g').attr('transform', `translate(${margin.left},${margin.top})`)\n\n // 축 생성 - 연도가 바뀌면 연도 포함\n const timeFormat = (date: Date) => {\n const dates = parsedData.map(d => d.date)\n const years = [...new Set(dates.map(d => d.getFullYear()))]\n\n // 여러 연도가 있으면 연도 포함\n if (years.length > 1) {\n return d3.timeFormat('%Y-%m')(date)\n } else {\n return d3.timeFormat('%m/%d')(date)\n }\n }\n\n const xAxis = d3.axisBottom(xScale).tickFormat(timeFormat as any).ticks(Math.min(parsedData.length, 10))\n\n const yAxis = d3.axisLeft(yScale).ticks(5)\n\n // X축 그리드 라인 추가\n g.append('g')\n .attr('class', 'grid')\n .attr('transform', `translate(0,${chartHeight})`)\n .call(\n d3\n .axisBottom(xScale)\n .ticks(Math.min(parsedData.length, 10))\n .tickSize(-chartHeight)\n .tickFormat(() => '')\n )\n\n g.append('g')\n .attr('class', 'axis')\n .attr('transform', `translate(0,${chartHeight})`)\n .call(xAxis)\n .selectAll('text')\n .style('text-anchor', 'end')\n .attr('dx', '-.5em')\n .attr('dy', '.3em')\n .attr('transform', 'rotate(-30)')\n\n g.append('g').attr('class', 'axis').call(yAxis)\n\n // 라인 생성기\n const line = d3\n .line<{ date: Date; value: number; color: string }>()\n .x(d => xScale(d.date))\n .y(d => yScale(d.value))\n .curve(d3.curveMonotoneX)\n\n // 트렌드 라인 그리기\n g.append('path')\n .datum(parsedData)\n .attr('class', 'trend-line')\n .attr('d', line as any)\n .attr('stroke', this.lineColor)\n .attr('stroke-width', this.strokeWidth)\n\n // 데이터 포인트 그리기\n if (this.showPoints) {\n g.selectAll('.data-point')\n .data(parsedData)\n .enter()\n .append('circle')\n .attr('class', 'data-point')\n .attr('cx', d => xScale(d.date))\n .attr('cy', d => yScale(d.value))\n .attr('r', this.pointRadius)\n .attr('stroke', d => d.color)\n .attr('fill', 'white')\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
google: any;
|
|
5
|
+
markerClusterer?: any;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export declare class CommonGoogleMap extends LitElement {
|
|
9
|
+
static styles: import("lit").CSSResult[];
|
|
10
|
+
center: any;
|
|
11
|
+
zoom: any;
|
|
12
|
+
locations: any[];
|
|
13
|
+
focused: any;
|
|
14
|
+
polygons: any;
|
|
15
|
+
polylines: any;
|
|
16
|
+
markers: any;
|
|
17
|
+
boundCoords: any;
|
|
18
|
+
controls: any;
|
|
19
|
+
clusterZoom: number;
|
|
20
|
+
map: any;
|
|
21
|
+
defaultCenter: any;
|
|
22
|
+
private _infoWindow;
|
|
23
|
+
private _markerClusterer;
|
|
24
|
+
private _buildMarkersTimer;
|
|
25
|
+
get anchor(): Element | null;
|
|
26
|
+
readyMap(): Promise<void>;
|
|
27
|
+
buildMarkers(locations?: any[]): Promise<void>;
|
|
28
|
+
get infoWindow(): any;
|
|
29
|
+
setFocus(focus: any, icon: any): void;
|
|
30
|
+
resetFocus(focus: any, icon: any): void;
|
|
31
|
+
changeFocus(after: any, before: any): Promise<void>;
|
|
32
|
+
updated(changes: any): Promise<void>;
|
|
33
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
34
|
+
resetBounds(): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { LitElement, html, css } from 'lit';
|
|
3
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
4
|
+
import { ScrollbarStyles } from '@operato/styles';
|
|
5
|
+
import GoogleMapLoader from './google-map-loader.js';
|
|
6
|
+
let CommonGoogleMap = class CommonGoogleMap extends LitElement {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.locations = [];
|
|
10
|
+
this.clusterZoom = 10;
|
|
11
|
+
this.map = null;
|
|
12
|
+
this.defaultCenter = { lat: 36.5, lng: 127.5 };
|
|
13
|
+
this._infoWindow = null;
|
|
14
|
+
this._markerClusterer = null;
|
|
15
|
+
this._buildMarkersTimer = null;
|
|
16
|
+
}
|
|
17
|
+
get anchor() {
|
|
18
|
+
return this.renderRoot.querySelector('[map]');
|
|
19
|
+
}
|
|
20
|
+
async readyMap() {
|
|
21
|
+
var _a;
|
|
22
|
+
await GoogleMapLoader.load();
|
|
23
|
+
// MarkerClusterer 라이브러리 로드
|
|
24
|
+
if (!window.markerClusterer) {
|
|
25
|
+
await GoogleMapLoader.loadMarkerClusterer();
|
|
26
|
+
}
|
|
27
|
+
if (this.map) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
// DOM이 준비될 때까지 기다림
|
|
31
|
+
await this.updateComplete;
|
|
32
|
+
// anchor가 준비될 때까지 기다림
|
|
33
|
+
let attempts = 0;
|
|
34
|
+
const maxAttempts = 20;
|
|
35
|
+
while (attempts < maxAttempts) {
|
|
36
|
+
const anchor = this.anchor;
|
|
37
|
+
if (anchor && anchor.offsetWidth > 0) {
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
await new Promise(resolve => setTimeout(resolve, 50));
|
|
41
|
+
attempts++;
|
|
42
|
+
}
|
|
43
|
+
if (!this.anchor) {
|
|
44
|
+
console.error('Map anchor element not found');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
var show = async (center, zoom) => {
|
|
48
|
+
try {
|
|
49
|
+
// Google Maps 최신 API 사용
|
|
50
|
+
const { Map } = (await google.maps.importLibrary('maps'));
|
|
51
|
+
const mapOptions = {
|
|
52
|
+
zoom,
|
|
53
|
+
center,
|
|
54
|
+
mapId: 'DEMO_MAP_ID'
|
|
55
|
+
};
|
|
56
|
+
// controls 속성이 있으면 지도 옵션에 추가
|
|
57
|
+
if (this.controls) {
|
|
58
|
+
Object.assign(mapOptions, this.controls);
|
|
59
|
+
}
|
|
60
|
+
const map = new Map(this.anchor, mapOptions);
|
|
61
|
+
this.markers && this.markers.forEach(marker => marker.setMap(map));
|
|
62
|
+
this.map = map;
|
|
63
|
+
this.dispatchEvent(new CustomEvent('map-change', {
|
|
64
|
+
detail: this.map
|
|
65
|
+
}));
|
|
66
|
+
this.resetBounds();
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
console.error(e);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var { center, zoom = 10 } = this;
|
|
73
|
+
/* center 속성이 설정되어있지 않으면, 현재 위치를 구해서 지도의 center로 설정한다. */
|
|
74
|
+
if (!center && 'geolocation' in navigator && !((_a = this.boundCoords) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
75
|
+
navigator.geolocation.getCurrentPosition(({ coords: { latitude: lat, longitude: lng } }) => show({ lat, lng }, zoom), err => {
|
|
76
|
+
console.warn(`navigator.geolocation.getCurrentPosition failed. (${err.code}): ${err.message}`);
|
|
77
|
+
show(this.defaultCenter, zoom);
|
|
78
|
+
}, {
|
|
79
|
+
/* https://stackoverflow.com/questions/3397585/navigator-geolocation-getcurrentposition-sometimes-works-sometimes-doesnt */
|
|
80
|
+
timeout: 500
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
show(center, zoom);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async buildMarkers(locations = []) {
|
|
88
|
+
if (!this.map) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (this.markers) {
|
|
92
|
+
this.markers.forEach(marker => marker.setMap(null));
|
|
93
|
+
this.markers = [];
|
|
94
|
+
}
|
|
95
|
+
// 기존 클러스터 제거
|
|
96
|
+
if (this._markerClusterer) {
|
|
97
|
+
this._markerClusterer.clearMarkers();
|
|
98
|
+
this._markerClusterer = null;
|
|
99
|
+
}
|
|
100
|
+
// Google Maps 최신 API 사용
|
|
101
|
+
const { AdvancedMarkerElement, PinElement } = (await google.maps.importLibrary('marker'));
|
|
102
|
+
this.markers = locations
|
|
103
|
+
.map(location => {
|
|
104
|
+
// location 객체가 유효한지 확인
|
|
105
|
+
if (!location || typeof location !== 'object') {
|
|
106
|
+
console.warn('Invalid location object:', location);
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
// lat, lng 값이 유효한지 확인
|
|
110
|
+
const lat = parseFloat(location.lat);
|
|
111
|
+
const lng = parseFloat(location.lng);
|
|
112
|
+
if (isNaN(lat) || isNaN(lng)) {
|
|
113
|
+
console.warn('Invalid lat/lng values:', location);
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
// LatLng 객체 생성
|
|
117
|
+
const position = new google.maps.LatLng(lat, lng);
|
|
118
|
+
// 커스텀 마커 콘텐츠가 있으면 사용
|
|
119
|
+
let markerElement;
|
|
120
|
+
if (location.markerContent) {
|
|
121
|
+
// HTML 문자열을 DOM 요소로 변환
|
|
122
|
+
const tempDiv = document.createElement('div');
|
|
123
|
+
tempDiv.innerHTML = location.markerContent;
|
|
124
|
+
markerElement = tempDiv.firstElementChild;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
// 기본 핀 사용
|
|
128
|
+
markerElement = new PinElement({
|
|
129
|
+
background: '#1976d2',
|
|
130
|
+
borderColor: '#1565c0',
|
|
131
|
+
glyphColor: '#ffffff',
|
|
132
|
+
scale: 1.2
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
// AdvancedMarkerElement 사용
|
|
136
|
+
const marker = new AdvancedMarkerElement({
|
|
137
|
+
position: position,
|
|
138
|
+
map: null, // 클러스터에서 관리하므로 지도에 직접 추가하지 않음
|
|
139
|
+
content: markerElement
|
|
140
|
+
});
|
|
141
|
+
marker.addListener('click', () => {
|
|
142
|
+
// InfoWindow 대신 커스텀 이벤트 발생
|
|
143
|
+
if (location === null || location === void 0 ? void 0 : location.region) {
|
|
144
|
+
this.dispatchEvent(new CustomEvent('region-click', {
|
|
145
|
+
detail: { region: location.region },
|
|
146
|
+
bubbles: true,
|
|
147
|
+
composed: true
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
return marker;
|
|
152
|
+
})
|
|
153
|
+
.filter(marker => marker !== null); // null 마커 제거
|
|
154
|
+
// Google Maps 공식 MarkerClusterer 사용 (예시와 동일한 방식)
|
|
155
|
+
if (this.markers.length > 0 && window.markerClusterer) {
|
|
156
|
+
this._markerClusterer = new window.markerClusterer.MarkerClusterer({
|
|
157
|
+
markers: this.markers,
|
|
158
|
+
map: this.map
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
get infoWindow() {
|
|
163
|
+
if (!this._infoWindow && this.map) {
|
|
164
|
+
this._infoWindow = new google.maps.InfoWindow({
|
|
165
|
+
content: 'loading...'
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
return this._infoWindow;
|
|
169
|
+
}
|
|
170
|
+
setFocus(focus, icon) {
|
|
171
|
+
focus.setZIndex(1);
|
|
172
|
+
focus.setIcon(icon);
|
|
173
|
+
}
|
|
174
|
+
resetFocus(focus, icon) {
|
|
175
|
+
focus.setZIndex(0);
|
|
176
|
+
focus.setIcon(icon);
|
|
177
|
+
}
|
|
178
|
+
async changeFocus(after, before) {
|
|
179
|
+
var _a;
|
|
180
|
+
await this.readyMap();
|
|
181
|
+
// map이 준비되지 않았으면 포커스 변경하지 않음
|
|
182
|
+
if (!this.map) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
var locations = this.locations || [];
|
|
186
|
+
if (before) {
|
|
187
|
+
var idx = locations.findIndex(location => {
|
|
188
|
+
// location 객체의 구조를 안전하게 확인
|
|
189
|
+
const beforePos = before === null || before === void 0 ? void 0 : before.position;
|
|
190
|
+
const locationPos = location === null || location === void 0 ? void 0 : location.position;
|
|
191
|
+
return ((location === null || location === void 0 ? void 0 : location.name) == (before === null || before === void 0 ? void 0 : before.name) && (locationPos === null || locationPos === void 0 ? void 0 : locationPos.lat) == (beforePos === null || beforePos === void 0 ? void 0 : beforePos.lat) && (locationPos === null || locationPos === void 0 ? void 0 : locationPos.lng) == (beforePos === null || beforePos === void 0 ? void 0 : beforePos.lng));
|
|
192
|
+
});
|
|
193
|
+
idx !== -1 && this.markers && this.resetFocus(this.markers[idx], (_a = locations[idx]) === null || _a === void 0 ? void 0 : _a.icon);
|
|
194
|
+
}
|
|
195
|
+
if (after) {
|
|
196
|
+
var idx = locations.findIndex(location => {
|
|
197
|
+
// location 객체의 구조를 안전하게 확인
|
|
198
|
+
const afterPos = after === null || after === void 0 ? void 0 : after.position;
|
|
199
|
+
const locationPos = location === null || location === void 0 ? void 0 : location.position;
|
|
200
|
+
return (location === null || location === void 0 ? void 0 : location.name) == (after === null || after === void 0 ? void 0 : after.name) && (locationPos === null || locationPos === void 0 ? void 0 : locationPos.lat) == (afterPos === null || afterPos === void 0 ? void 0 : afterPos.lat) && (locationPos === null || locationPos === void 0 ? void 0 : locationPos.lng) == (afterPos === null || afterPos === void 0 ? void 0 : afterPos.lng);
|
|
201
|
+
});
|
|
202
|
+
idx !== -1 && this.markers && this.setFocus(this.markers[idx], after === null || after === void 0 ? void 0 : after.icon);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
async updated(changes) {
|
|
206
|
+
if (!this.map) {
|
|
207
|
+
await this.readyMap();
|
|
208
|
+
}
|
|
209
|
+
if (changes.has('locations')) {
|
|
210
|
+
// 디바운스: 연속된 업데이트를 하나로 묶음
|
|
211
|
+
if (this._buildMarkersTimer) {
|
|
212
|
+
clearTimeout(this._buildMarkersTimer);
|
|
213
|
+
}
|
|
214
|
+
this._buildMarkersTimer = setTimeout(() => {
|
|
215
|
+
this.buildMarkers(this.locations);
|
|
216
|
+
this._buildMarkersTimer = null;
|
|
217
|
+
}, 500);
|
|
218
|
+
}
|
|
219
|
+
if (changes.has('focused')) {
|
|
220
|
+
this.changeFocus(this.focused, changes.get('focused'));
|
|
221
|
+
}
|
|
222
|
+
if (changes.has('center')) {
|
|
223
|
+
this.map.setCenter(this.center);
|
|
224
|
+
}
|
|
225
|
+
if (changes.has('controls')) {
|
|
226
|
+
// controls가 변경되면 기존 지도의 옵션만 업데이트
|
|
227
|
+
if (this.map && this.controls) {
|
|
228
|
+
// Google Maps API의 setOptions 메서드 사용
|
|
229
|
+
this.map.setOptions(this.controls);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (changes.has('polygons')) {
|
|
233
|
+
;
|
|
234
|
+
(changes.get('polygons') || []).forEach(geofence => geofence.setMap(null));
|
|
235
|
+
(this.polygons || []).forEach(geofence => geofence.setMap(this.map));
|
|
236
|
+
}
|
|
237
|
+
if (changes.has('polylines')) {
|
|
238
|
+
;
|
|
239
|
+
(changes.get('polylines') || []).forEach(polyline => polyline.setMap(null));
|
|
240
|
+
(this.polylines || []).forEach(polyline => polyline.setMap(this.map));
|
|
241
|
+
}
|
|
242
|
+
if (changes.has('markers')) {
|
|
243
|
+
;
|
|
244
|
+
(changes.get('markers') || []).forEach(marker => marker.setMap(null));
|
|
245
|
+
(this.markers || []).forEach(marker => marker.setMap(this.map));
|
|
246
|
+
}
|
|
247
|
+
if (changes.has('boundCoords')) {
|
|
248
|
+
this.resetBounds();
|
|
249
|
+
}
|
|
250
|
+
// 클러스터링 설정 변경 시 마커 재구성
|
|
251
|
+
if (changes.has('clusterZoom')) {
|
|
252
|
+
this.buildMarkers(this.locations);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
render() {
|
|
256
|
+
return html ` <div map></div> `;
|
|
257
|
+
}
|
|
258
|
+
resetBounds() {
|
|
259
|
+
if (!this.boundCoords || this.boundCoords.length < 1 || !this.map) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
var bounds = new google.maps.LatLngBounds();
|
|
263
|
+
this.boundCoords.forEach(coord => bounds.extend(coord));
|
|
264
|
+
this.map.fitBounds(bounds);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
CommonGoogleMap.styles = [
|
|
268
|
+
ScrollbarStyles,
|
|
269
|
+
css `
|
|
270
|
+
:host {
|
|
271
|
+
display: flex;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
[map] {
|
|
275
|
+
flex: 1;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.gm-style .gm-style-iw-c {
|
|
279
|
+
padding: 0;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.gm-style .gm-style-iw-d {
|
|
283
|
+
overflow: auto !important;
|
|
284
|
+
}
|
|
285
|
+
.gm-style .gm-style-iw-d + button {
|
|
286
|
+
top: 0 !important;
|
|
287
|
+
right: 0 !important;
|
|
288
|
+
}
|
|
289
|
+
`
|
|
290
|
+
];
|
|
291
|
+
__decorate([
|
|
292
|
+
property({ type: Object }),
|
|
293
|
+
__metadata("design:type", Object)
|
|
294
|
+
], CommonGoogleMap.prototype, "center", void 0);
|
|
295
|
+
__decorate([
|
|
296
|
+
property({ type: Number }),
|
|
297
|
+
__metadata("design:type", Object)
|
|
298
|
+
], CommonGoogleMap.prototype, "zoom", void 0);
|
|
299
|
+
__decorate([
|
|
300
|
+
property({ type: Array }),
|
|
301
|
+
__metadata("design:type", Array)
|
|
302
|
+
], CommonGoogleMap.prototype, "locations", void 0);
|
|
303
|
+
__decorate([
|
|
304
|
+
property({ type: Object }),
|
|
305
|
+
__metadata("design:type", Object)
|
|
306
|
+
], CommonGoogleMap.prototype, "focused", void 0);
|
|
307
|
+
__decorate([
|
|
308
|
+
property({ type: Array }),
|
|
309
|
+
__metadata("design:type", Object)
|
|
310
|
+
], CommonGoogleMap.prototype, "polygons", void 0);
|
|
311
|
+
__decorate([
|
|
312
|
+
property({ type: Array }),
|
|
313
|
+
__metadata("design:type", Object)
|
|
314
|
+
], CommonGoogleMap.prototype, "polylines", void 0);
|
|
315
|
+
__decorate([
|
|
316
|
+
property({ type: Array }),
|
|
317
|
+
__metadata("design:type", Object)
|
|
318
|
+
], CommonGoogleMap.prototype, "markers", void 0);
|
|
319
|
+
__decorate([
|
|
320
|
+
property({ type: Array }),
|
|
321
|
+
__metadata("design:type", Object)
|
|
322
|
+
], CommonGoogleMap.prototype, "boundCoords", void 0);
|
|
323
|
+
__decorate([
|
|
324
|
+
property({ type: Object }),
|
|
325
|
+
__metadata("design:type", Object)
|
|
326
|
+
], CommonGoogleMap.prototype, "controls", void 0);
|
|
327
|
+
__decorate([
|
|
328
|
+
property({ type: Number }),
|
|
329
|
+
__metadata("design:type", Object)
|
|
330
|
+
], CommonGoogleMap.prototype, "clusterZoom", void 0);
|
|
331
|
+
__decorate([
|
|
332
|
+
state(),
|
|
333
|
+
__metadata("design:type", Object)
|
|
334
|
+
], CommonGoogleMap.prototype, "map", void 0);
|
|
335
|
+
__decorate([
|
|
336
|
+
state(),
|
|
337
|
+
__metadata("design:type", Object)
|
|
338
|
+
], CommonGoogleMap.prototype, "defaultCenter", void 0);
|
|
339
|
+
CommonGoogleMap = __decorate([
|
|
340
|
+
customElement('common-google-map')
|
|
341
|
+
], CommonGoogleMap);
|
|
342
|
+
export { CommonGoogleMap };
|
|
343
|
+
//# sourceMappingURL=common-google-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common-google-map.js","sourceRoot":"","sources":["../../client/google-map/common-google-map.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,eAAe,MAAM,wBAAwB,CAAA;AAwB7C,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,UAAU;IAAxC;;QA4BsB,cAAS,GAAU,EAAE,CAAA;QAOpB,gBAAW,GAAG,EAAE,CAAA;QAEnC,QAAG,GAAQ,IAAI,CAAA;QACf,kBAAa,GAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;QAC/C,gBAAW,GAAQ,IAAI,CAAA;QACvB,qBAAgB,GAAQ,IAAI,CAAA;QAC5B,uBAAkB,GAAQ,IAAI,CAAA;IAoTxC,CAAC;IAlTC,IAAI,MAAM;QACR,O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,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;+CAAO;AACN;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6CAAK;AACL;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;kDAAsB;AACpB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDAAQ;AACR;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;iDAAS;AACR;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;kDAAU;AACT;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;gDAAQ;AACP;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;oDAAY;AACV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;iDAAS;AACR;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDAAiB;AAEnC;IAAR,KAAK,EAAE;;4CAAgB;AACf;IAAR,KAAK,EAAE;;sDAA+C;AAtC5C,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CA6V3B","sourcesContent":["import { LitElement, html, css } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { ScrollbarStyles } from '@operato/styles'\n\nimport GoogleMapLoader from './google-map-loader.js'\n\ndeclare global {\n interface Window {\n google: any\n markerClusterer?: any\n }\n}\n\ndeclare const google: any\n\ndeclare namespace google.maps {\n interface MapsLibrary {\n Map: any\n InfoWindow: any\n }\n\n interface MarkerLibrary {\n AdvancedMarkerElement: any\n PinElement: any\n }\n}\n\n@customElement('common-google-map')\nexport class CommonGoogleMap extends LitElement {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n }\n\n [map] {\n flex: 1;\n }\n\n .gm-style .gm-style-iw-c {\n padding: 0;\n }\n\n .gm-style .gm-style-iw-d {\n overflow: auto !important;\n }\n .gm-style .gm-style-iw-d + button {\n top: 0 !important;\n right: 0 !important;\n }\n `\n ]\n\n @property({ type: Object }) center\n @property({ type: Number }) zoom\n @property({ type: Array }) locations: any[] = []\n @property({ type: Object }) focused\n @property({ type: Array }) polygons\n @property({ type: Array }) polylines\n @property({ type: Array }) markers\n @property({ type: Array }) boundCoords\n @property({ type: Object }) controls\n @property({ type: Number }) clusterZoom = 10\n\n @state() map: any = null\n @state() defaultCenter: any = { lat: 36.5, lng: 127.5 }\n private _infoWindow: any = null\n private _markerClusterer: any = null\n private _buildMarkersTimer: any = null\n\n get anchor() {\n return this.renderRoot.querySelector('[map]')\n }\n\n async readyMap() {\n await GoogleMapLoader.load()\n\n // MarkerClusterer 라이브러리 로드\n if (!window.markerClusterer) {\n await GoogleMapLoader.loadMarkerClusterer()\n }\n\n if (this.map) {\n return\n }\n\n // DOM이 준비될 때까지 기다림\n await this.updateComplete\n\n // anchor가 준비될 때까지 기다림\n let attempts = 0\n const maxAttempts = 20\n while (attempts < maxAttempts) {\n const anchor = this.anchor as HTMLElement\n if (anchor && anchor.offsetWidth > 0) {\n break\n }\n await new Promise(resolve => setTimeout(resolve, 50))\n attempts++\n }\n\n if (!this.anchor) {\n console.error('Map anchor element not found')\n return\n }\n\n var show = async (center, zoom) => {\n try {\n // Google Maps 최신 API 사용\n const { Map } = (await google.maps.importLibrary('maps')) as google.maps.MapsLibrary\n\n const mapOptions = {\n zoom,\n center,\n mapId: 'DEMO_MAP_ID'\n }\n\n // controls 속성이 있으면 지도 옵션에 추가\n if (this.controls) {\n Object.assign(mapOptions, this.controls)\n }\n\n const map = new Map(this.anchor, mapOptions)\n\n this.markers && this.markers.forEach(marker => marker.setMap(map))\n\n this.map = map\n\n this.dispatchEvent(\n new CustomEvent('map-change', {\n detail: this.map\n })\n )\n\n this.resetBounds()\n } catch (e) {\n console.error(e)\n }\n }\n\n var { center, zoom = 10 } = this\n\n /* center 속성이 설정되어있지 않으면, 현재 위치를 구해서 지도의 center로 설정한다. */\n if (!center && 'geolocation' in navigator && !this.boundCoords?.length) {\n navigator.geolocation.getCurrentPosition(\n ({ coords: { latitude: lat, longitude: lng } }) => show({ lat, lng }, zoom),\n err => {\n console.warn(`navigator.geolocation.getCurrentPosition failed. (${err.code}): ${err.message}`)\n show(this.defaultCenter, zoom)\n },\n {\n /* https://stackoverflow.com/questions/3397585/navigator-geolocation-getcurrentposition-sometimes-works-sometimes-doesnt */\n timeout: 500\n }\n )\n } else {\n show(center, zoom)\n }\n }\n\n async buildMarkers(locations: any[] = []) {\n if (!this.map) {\n return\n }\n\n if (this.markers) {\n this.markers.forEach(marker => marker.setMap(null))\n this.markers = []\n }\n\n // 기존 클러스터 제거\n if (this._markerClusterer) {\n this._markerClusterer.clearMarkers()\n this._markerClusterer = null\n }\n\n // Google Maps 최신 API 사용\n const { AdvancedMarkerElement, PinElement } = (await google.maps.importLibrary(\n 'marker'\n )) as google.maps.MarkerLibrary\n\n this.markers = locations\n .map(location => {\n // location 객체가 유효한지 확인\n if (!location || typeof location !== 'object') {\n console.warn('Invalid location object:', location)\n return null\n }\n\n // lat, lng 값이 유효한지 확인\n const lat = parseFloat(location.lat)\n const lng = parseFloat(location.lng)\n\n if (isNaN(lat) || isNaN(lng)) {\n console.warn('Invalid lat/lng values:', location)\n return null\n }\n\n // LatLng 객체 생성\n const position = new google.maps.LatLng(lat, lng)\n\n // 커스텀 마커 콘텐츠가 있으면 사용\n let markerElement\n if (location.markerContent) {\n // HTML 문자열을 DOM 요소로 변환\n const tempDiv = document.createElement('div')\n tempDiv.innerHTML = location.markerContent\n markerElement = tempDiv.firstElementChild\n } else {\n // 기본 핀 사용\n markerElement = new PinElement({\n background: '#1976d2',\n borderColor: '#1565c0',\n glyphColor: '#ffffff',\n scale: 1.2\n })\n }\n\n // AdvancedMarkerElement 사용\n const marker = new AdvancedMarkerElement({\n position: position,\n map: null, // 클러스터에서 관리하므로 지도에 직접 추가하지 않음\n content: markerElement\n })\n\n marker.addListener('click', () => {\n // InfoWindow 대신 커스텀 이벤트 발생\n if (location?.region) {\n this.dispatchEvent(\n new CustomEvent('region-click', {\n detail: { region: location.region },\n bubbles: true,\n composed: true\n })\n )\n }\n })\n\n return marker\n })\n .filter(marker => marker !== null) // null 마커 제거\n\n // Google Maps 공식 MarkerClusterer 사용 (예시와 동일한 방식)\n if (this.markers.length > 0 && window.markerClusterer) {\n this._markerClusterer = new window.markerClusterer.MarkerClusterer({\n markers: this.markers,\n map: this.map\n })\n }\n }\n\n get infoWindow() {\n if (!this._infoWindow && this.map) {\n this._infoWindow = new google.maps.InfoWindow({\n content: 'loading...'\n })\n }\n\n return this._infoWindow\n }\n\n setFocus(focus, icon) {\n focus.setZIndex(1)\n focus.setIcon(icon)\n }\n\n resetFocus(focus, icon) {\n focus.setZIndex(0)\n focus.setIcon(icon)\n }\n\n async changeFocus(after, before) {\n await this.readyMap()\n\n // map이 준비되지 않았으면 포커스 변경하지 않음\n if (!this.map) {\n return\n }\n\n var locations = this.locations || []\n\n if (before) {\n var idx = locations.findIndex(location => {\n // location 객체의 구조를 안전하게 확인\n const beforePos = before?.position\n const locationPos = location?.position\n\n return (\n location?.name == before?.name && locationPos?.lat == beforePos?.lat && locationPos?.lng == beforePos?.lng\n )\n })\n idx !== -1 && this.markers && this.resetFocus(this.markers[idx], locations[idx]?.icon)\n }\n\n if (after) {\n var idx = locations.findIndex(location => {\n // location 객체의 구조를 안전하게 확인\n const afterPos = after?.position\n const locationPos = location?.position\n\n return location?.name == after?.name && locationPos?.lat == afterPos?.lat && locationPos?.lng == afterPos?.lng\n })\n idx !== -1 && this.markers && this.setFocus(this.markers[idx], after?.icon)\n }\n }\n\n async updated(changes) {\n if (!this.map) {\n await this.readyMap()\n }\n\n if (changes.has('locations')) {\n // 디바운스: 연속된 업데이트를 하나로 묶음\n if (this._buildMarkersTimer) {\n clearTimeout(this._buildMarkersTimer)\n }\n this._buildMarkersTimer = setTimeout(() => {\n this.buildMarkers(this.locations)\n this._buildMarkersTimer = null\n }, 500)\n }\n\n if (changes.has('focused')) {\n this.changeFocus(this.focused, changes.get('focused'))\n }\n\n if (changes.has('center')) {\n this.map.setCenter(this.center)\n }\n\n if (changes.has('controls')) {\n // controls가 변경되면 기존 지도의 옵션만 업데이트\n if (this.map && this.controls) {\n // Google Maps API의 setOptions 메서드 사용\n this.map.setOptions(this.controls)\n }\n }\n\n if (changes.has('polygons')) {\n ;(changes.get('polygons') || []).forEach(geofence => geofence.setMap(null))\n ;(this.polygons || []).forEach(geofence => geofence.setMap(this.map))\n }\n\n if (changes.has('polylines')) {\n ;(changes.get('polylines') || []).forEach(polyline => polyline.setMap(null))\n ;(this.polylines || []).forEach(polyline => polyline.setMap(this.map))\n }\n\n if (changes.has('markers')) {\n ;(changes.get('markers') || []).forEach(marker => marker.setMap(null))\n ;(this.markers || []).forEach(marker => marker.setMap(this.map))\n }\n\n if (changes.has('boundCoords')) {\n this.resetBounds()\n }\n\n // 클러스터링 설정 변경 시 마커 재구성\n if (changes.has('clusterZoom')) {\n this.buildMarkers(this.locations)\n }\n }\n\n render() {\n return html` <div map></div> `\n }\n\n resetBounds() {\n if (!this.boundCoords || this.boundCoords.length < 1 || !this.map) {\n return\n }\n\n var bounds = new google.maps.LatLngBounds()\n this.boundCoords.forEach(coord => bounds.extend(coord))\n this.map.fitBounds(bounds)\n }\n}\n"]}
|