@haloduck/ui 2.0.6 → 2.0.7
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/fesm2022/haloduck-ui.mjs +44 -7
- package/fesm2022/haloduck-ui.mjs.map +1 -1
- package/index.d.ts +4 -0
- package/package.json +1 -1
package/fesm2022/haloduck-ui.mjs
CHANGED
|
@@ -2154,10 +2154,21 @@ class MapToAddressComponent {
|
|
|
2154
2154
|
disabled = false;
|
|
2155
2155
|
currentLngLat;
|
|
2156
2156
|
_currentAddress;
|
|
2157
|
+
_isGoogleLoaded = false;
|
|
2158
|
+
_loadError;
|
|
2159
|
+
get isGoogleLoaded() {
|
|
2160
|
+
return this._isGoogleLoaded;
|
|
2161
|
+
}
|
|
2162
|
+
get loadError() {
|
|
2163
|
+
return this._loadError;
|
|
2164
|
+
}
|
|
2157
2165
|
set currentAddress(value) {
|
|
2158
2166
|
if (value) {
|
|
2159
2167
|
this._currentAddress = value;
|
|
2160
|
-
|
|
2168
|
+
// Google Maps API가 로드된 후에만 실행
|
|
2169
|
+
if (this._isGoogleLoaded) {
|
|
2170
|
+
this.setMapToAddress();
|
|
2171
|
+
}
|
|
2161
2172
|
}
|
|
2162
2173
|
}
|
|
2163
2174
|
locationChanged = new EventEmitter();
|
|
@@ -2167,12 +2178,24 @@ class MapToAddressComponent {
|
|
|
2167
2178
|
onChange = () => { };
|
|
2168
2179
|
onTouched = () => { };
|
|
2169
2180
|
async ngOnInit() {
|
|
2170
|
-
|
|
2171
|
-
|
|
2181
|
+
try {
|
|
2182
|
+
await this.initScript();
|
|
2183
|
+
this._isGoogleLoaded = true;
|
|
2184
|
+
this.initMap();
|
|
2185
|
+
// API 로드 완료 후 pending된 주소 설정 실행
|
|
2186
|
+
if (this._currentAddress) {
|
|
2187
|
+
this.setMapToAddress();
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
catch (error) {
|
|
2191
|
+
this._loadError = 'Google Maps API를 로드할 수 없습니다.';
|
|
2192
|
+
isDevMode() && console.error('Failed to load Google Maps API:', error);
|
|
2193
|
+
}
|
|
2172
2194
|
}
|
|
2173
2195
|
initScript() {
|
|
2174
2196
|
return new Promise((resolve, reject) => {
|
|
2175
2197
|
if (typeof google !== 'undefined') {
|
|
2198
|
+
this._isGoogleLoaded = true;
|
|
2176
2199
|
resolve();
|
|
2177
2200
|
return;
|
|
2178
2201
|
}
|
|
@@ -2180,7 +2203,10 @@ class MapToAddressComponent {
|
|
|
2180
2203
|
script.src = `https://maps.googleapis.com/maps/api/js?key=${this.coreService.getGoogleApiKey()}&libraries=places,marker&loading=sync`;
|
|
2181
2204
|
script.async = false;
|
|
2182
2205
|
script.defer = true;
|
|
2183
|
-
script.onload = () =>
|
|
2206
|
+
script.onload = () => {
|
|
2207
|
+
this._isGoogleLoaded = true;
|
|
2208
|
+
resolve();
|
|
2209
|
+
};
|
|
2184
2210
|
script.onerror = (error) => reject(error);
|
|
2185
2211
|
document.head.appendChild(script);
|
|
2186
2212
|
isDevMode() && console.log('Google Maps script loaded', script);
|
|
@@ -2256,6 +2282,10 @@ class MapToAddressComponent {
|
|
|
2256
2282
|
}
|
|
2257
2283
|
}
|
|
2258
2284
|
setMapToAddress() {
|
|
2285
|
+
if (!this._isGoogleLoaded) {
|
|
2286
|
+
isDevMode() && console.warn('Google Maps API not loaded yet');
|
|
2287
|
+
return;
|
|
2288
|
+
}
|
|
2259
2289
|
const geocoder = new google.maps.Geocoder();
|
|
2260
2290
|
geocoder.geocode({ address: this._currentAddress }, (results, status) => {
|
|
2261
2291
|
if (status === 'OK' && results[0]) {
|
|
@@ -2269,6 +2299,10 @@ class MapToAddressComponent {
|
|
|
2269
2299
|
});
|
|
2270
2300
|
}
|
|
2271
2301
|
getAddress() {
|
|
2302
|
+
if (!this._isGoogleLoaded) {
|
|
2303
|
+
isDevMode() && console.warn('Google Maps API not loaded yet');
|
|
2304
|
+
return;
|
|
2305
|
+
}
|
|
2272
2306
|
const geocoder = new google.maps.Geocoder();
|
|
2273
2307
|
const position = this.marker.position;
|
|
2274
2308
|
if (!position) {
|
|
@@ -2320,7 +2354,10 @@ class MapToAddressComponent {
|
|
|
2320
2354
|
if (value) {
|
|
2321
2355
|
this.location = value;
|
|
2322
2356
|
this.currentLngLat = { lat: value.lat, lng: value.lng };
|
|
2323
|
-
|
|
2357
|
+
// Google Maps API가 로드된 후에만 맵 초기화
|
|
2358
|
+
if (this._isGoogleLoaded) {
|
|
2359
|
+
this.initializeMap(this.currentLngLat);
|
|
2360
|
+
}
|
|
2324
2361
|
}
|
|
2325
2362
|
}
|
|
2326
2363
|
registerOnChange(fn) {
|
|
@@ -2339,7 +2376,7 @@ class MapToAddressComponent {
|
|
|
2339
2376
|
useExisting: MapToAddressComponent,
|
|
2340
2377
|
multi: true,
|
|
2341
2378
|
},
|
|
2342
|
-
], ngImport: i0, template: "<div id=\"map\" class=\"w-full h-full\"></div
|
|
2379
|
+
], ngImport: i0, template: "<div class=\"w-full h-full relative\">\n <!-- \uB85C\uB529 \uC0C1\uD0DC -->\n <div\n *ngIf=\"!isGoogleLoaded && !loadError\"\n class=\"absolute inset-0 flex items-center justify-center bg-gray-100 z-10\"\n >\n <div class=\"text-center\">\n <div class=\"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500 mx-auto mb-2\"></div>\n <p class=\"text-gray-600 text-sm\">\uC9C0\uB3C4\uB97C \uB85C\uB529 \uC911\uC785\uB2C8\uB2E4...</p>\n </div>\n </div>\n\n <!-- \uC5D0\uB7EC \uC0C1\uD0DC -->\n <div\n *ngIf=\"loadError\"\n class=\"absolute inset-0 flex items-center justify-center bg-red-50 z-10\"\n >\n <div class=\"text-center p-4\">\n <div class=\"text-red-500 text-2xl mb-2\">\u26A0\uFE0F</div>\n <p class=\"text-red-700 text-sm font-medium\">{{ loadError }}</p>\n <p class=\"text-red-600 text-xs mt-1\">\uC778\uD130\uB137 \uC5F0\uACB0\uC744 \uD655\uC778\uD558\uACE0 \uD398\uC774\uC9C0\uB97C \uC0C8\uB85C\uACE0\uCE68\uD574 \uC8FC\uC138\uC694.</p>\n </div>\n </div>\n\n <div id=\"map\" class=\"w-full h-full\"></div>\n</div>\n", styles: ["#map{border:1px solid #ccc;margin-bottom:10px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: FormsModule }] });
|
|
2343
2380
|
}
|
|
2344
2381
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: MapToAddressComponent, decorators: [{
|
|
2345
2382
|
type: Component,
|
|
@@ -2349,7 +2386,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImpor
|
|
|
2349
2386
|
useExisting: MapToAddressComponent,
|
|
2350
2387
|
multi: true,
|
|
2351
2388
|
},
|
|
2352
|
-
], template: "<div id=\"map\" class=\"w-full h-full\"></div
|
|
2389
|
+
], template: "<div class=\"w-full h-full relative\">\n <!-- \uB85C\uB529 \uC0C1\uD0DC -->\n <div\n *ngIf=\"!isGoogleLoaded && !loadError\"\n class=\"absolute inset-0 flex items-center justify-center bg-gray-100 z-10\"\n >\n <div class=\"text-center\">\n <div class=\"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500 mx-auto mb-2\"></div>\n <p class=\"text-gray-600 text-sm\">\uC9C0\uB3C4\uB97C \uB85C\uB529 \uC911\uC785\uB2C8\uB2E4...</p>\n </div>\n </div>\n\n <!-- \uC5D0\uB7EC \uC0C1\uD0DC -->\n <div\n *ngIf=\"loadError\"\n class=\"absolute inset-0 flex items-center justify-center bg-red-50 z-10\"\n >\n <div class=\"text-center p-4\">\n <div class=\"text-red-500 text-2xl mb-2\">\u26A0\uFE0F</div>\n <p class=\"text-red-700 text-sm font-medium\">{{ loadError }}</p>\n <p class=\"text-red-600 text-xs mt-1\">\uC778\uD130\uB137 \uC5F0\uACB0\uC744 \uD655\uC778\uD558\uACE0 \uD398\uC774\uC9C0\uB97C \uC0C8\uB85C\uACE0\uCE68\uD574 \uC8FC\uC138\uC694.</p>\n </div>\n </div>\n\n <div id=\"map\" class=\"w-full h-full\"></div>\n</div>\n", styles: ["#map{border:1px solid #ccc;margin-bottom:10px}\n"] }]
|
|
2353
2390
|
}], propDecorators: { disabled: [{
|
|
2354
2391
|
type: Input
|
|
2355
2392
|
}], currentLngLat: [{
|