지도크기오류 수정
This commit is contained in:
@@ -2,16 +2,16 @@
|
||||
import { WiFiHotspot } from '../types';
|
||||
|
||||
const API_Base_URL = '/api/markers';
|
||||
const isDebug = import.meta.env.DEV;
|
||||
|
||||
export const apiService = {
|
||||
getHotspots: async (): Promise<WiFiHotspot[]> => {
|
||||
const fullUrl = `${window.location.origin}${API_Base_URL}`;
|
||||
console.log(`[API Call] GET ${fullUrl} (Origin: ${window.location.origin})`);
|
||||
if (isDebug) console.log(`[API Call] GET ${window.location.origin}${API_Base_URL}`);
|
||||
try {
|
||||
const response = await fetch(API_Base_URL, { cache: 'no-store' }); // 캐시 방지 추가
|
||||
const response = await fetch(API_Base_URL, { cache: 'no-store' });
|
||||
if (!response.ok) throw new Error('Failed to fetch markers');
|
||||
const data = await response.json();
|
||||
console.log(`[API Response] Received ${data.length} hotspots`, data);
|
||||
if (isDebug) console.log(`[API Response] Received ${data.length} hotspots`, data);
|
||||
return data;
|
||||
} catch (e) {
|
||||
console.error("Failed to load hotspots from API", e);
|
||||
@@ -20,7 +20,7 @@ export const apiService = {
|
||||
},
|
||||
|
||||
saveHotspot: async (hotspot: WiFiHotspot): Promise<void> => {
|
||||
console.log(`[API Call] POST ${API_Base_URL}`, hotspot);
|
||||
if (isDebug) console.log(`[API Call] POST ${API_Base_URL}`, hotspot);
|
||||
try {
|
||||
const response = await fetch(API_Base_URL, {
|
||||
method: 'POST',
|
||||
@@ -31,7 +31,7 @@ export const apiService = {
|
||||
});
|
||||
if (!response.ok) throw new Error('Failed to save marker');
|
||||
const data = await response.json();
|
||||
console.log(`[API Response] Save success:`, data);
|
||||
if (isDebug) console.log(`[API Response] Save success:`, data);
|
||||
// Trigger a storage event to refresh UI if needed (keeping compatibility)
|
||||
window.dispatchEvent(new Event('storage_updated'));
|
||||
} catch (e) {
|
||||
@@ -41,14 +41,14 @@ export const apiService = {
|
||||
|
||||
deleteHotspot: async (id: string): Promise<void> => {
|
||||
const url = `${API_Base_URL}/${id}`;
|
||||
console.log(`[API Call] DELETE ${url}`);
|
||||
if (isDebug) console.log(`[API Call] DELETE ${url}`);
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
if (!response.ok) throw new Error('Failed to delete marker');
|
||||
const data = await response.json();
|
||||
console.log(`[API Response] Delete success:`, data);
|
||||
if (isDebug) console.log(`[API Response] Delete success:`, data);
|
||||
window.dispatchEvent(new Event('storage_updated'));
|
||||
} catch (e) {
|
||||
console.error("Failed to delete hotspot", e);
|
||||
|
||||
@@ -3,6 +3,7 @@ import { GoogleGenAI, Type } from "@google/genai";
|
||||
|
||||
const apiKey = import.meta.env.VITE_GEMINI_API_KEY || process.env.GEMINI_API_KEY || process.env.API_KEY || '';
|
||||
if (!apiKey) console.error("API Key is missing!");
|
||||
const isDebug = import.meta.env.DEV;
|
||||
const ai = new GoogleGenAI({ apiKey });
|
||||
|
||||
export interface DetailedSearchResult {
|
||||
@@ -15,7 +16,7 @@ export interface DetailedSearchResult {
|
||||
export const geminiService = {
|
||||
async searchNearbyWiFi(query: string, location: { lat: number, lng: number }) {
|
||||
try {
|
||||
console.log("Stage 1: 정보 검색 시작...");
|
||||
if (isDebug) console.log("Stage 1: 정보 검색 시작...");
|
||||
|
||||
// Stage 1: Google Search/Maps Grounding을 통해 원시 데이터 확보
|
||||
const searchResponse = await ai.models.generateContent({
|
||||
@@ -36,13 +37,13 @@ export const geminiService = {
|
||||
});
|
||||
|
||||
const rawText = searchResponse.text || "";
|
||||
console.log("Stage 1 원문 결과:", rawText);
|
||||
if (isDebug) console.log("Stage 1 원문 결과:", rawText);
|
||||
|
||||
if (!rawText) {
|
||||
return { text: "검색 결과를 가져오지 못했습니다.", results: [] };
|
||||
}
|
||||
|
||||
console.log("Stage 2: 데이터 구조화 추출 시작...");
|
||||
if (isDebug) console.log("Stage 2: 데이터 구조화 추출 시작...");
|
||||
|
||||
// Stage 2: 획득한 텍스트에서 JSON 형태로 좌표 및 정보 정밀 추출
|
||||
const parseResponse = await ai.models.generateContent({
|
||||
@@ -74,7 +75,7 @@ export const geminiService = {
|
||||
let results: DetailedSearchResult[] = [];
|
||||
try {
|
||||
results = JSON.parse(parseResponse.text || "[]");
|
||||
console.log("Stage 2 추출 성공:", results);
|
||||
if (isDebug) console.log("Stage 2 추출 성공:", results);
|
||||
} catch (e) {
|
||||
console.error("JSON 파싱 실패:", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user