upload 기능 구현 전에 일단 커밋

This commit is contained in:
2026-08-20 16:00:15 +09:00
commit 2ed3c72b77
24 changed files with 4959 additions and 0 deletions
+413
View File
@@ -0,0 +1,413 @@
.app {
width: 100vw;
height: 100vh;
position: relative;
}
.map-container {
width: 100%;
height: 100%;
background-color: #eee;
}
.overlay {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
background-color: rgba(0, 0, 0, 0.4);
z-index: 20;
color: white;
font-size: 18px;
font-weight: bold;
}
.error-banner {
position: absolute;
top: 20px;
left: 50%;
transform: translateX(-50%);
background-color: #ef4444;
color: white;
padding: 12px 24px;
border-radius: 8px;
z-index: 30;
font-weight: bold;
}
.capture-bar {
position: absolute;
bottom: 80px;
left: 50%;
transform: translateX(-50%);
z-index: 10;
display: flex;
gap: 12px;
align-items: center;
}
.camera-input {
display: none;
}
.capture-button {
padding: 15px 30px;
background-color: #10b981;
color: white;
border-radius: 30px;
font-weight: bold;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
cursor: pointer;
display: inline-block;
}
.locate-btn {
width: 48px;
height: 48px;
border-radius: 50%;
border: none;
background-color: white;
font-size: 20px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.upload-progress {
position: absolute;
bottom: 80px;
left: 50%;
transform: translateX(-50%);
background: rgba(0, 0, 0, 0.75);
color: white;
padding: 10px 20px;
border-radius: 20px;
z-index: 15;
font-size: 14px;
font-weight: 500;
white-space: nowrap;
}
.list-toggle {
position: absolute;
top: 10px;
right: 10px;
background-color: white;
padding: 8px 16px;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
z-index: 10;
font-size: 14px;
font-weight: bold;
border: none;
cursor: pointer;
}
.gps-info {
position: absolute;
top: 50px;
right: 10px;
color: white;
padding: 8px 12px;
border-radius: 8px;
z-index: 10;
font-size: 12px;
max-width: 200px;
line-height: 1.4;
}
.gps-info--fallback {
background-color: #f59e0b;
}
.gps-info--normal {
background-color: #10b981;
}
.gps-info__title {
font-weight: bold;
}
.backdrop {
position: absolute;
inset: 0;
background-color: rgba(0, 0, 0, 0.3);
z-index: 40;
}
.pole-list {
position: absolute;
top: 50px;
right: 10px;
width: min(320px, calc(100vw - 20px));
background-color: white;
border-radius: 12px;
z-index: 50;
transition: max-height 0.3s ease, opacity 0.2s ease;
overflow: hidden;
display: flex;
flex-direction: column;
}
.pole-list--open {
max-height: 75vh;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
opacity: 1;
pointer-events: auto;
}
.pole-list--closed {
max-height: 0;
box-shadow: none;
opacity: 0;
pointer-events: none;
}
.pole-list__header {
padding: 12px 16px;
border-bottom: 1px solid #e5e7eb;
display: flex;
justify-content: space-between;
align-items: center;
flex-shrink: 0;
}
.pole-list__title {
font-weight: bold;
font-size: 14px;
}
.pole-list__close {
background: none;
border: none;
font-size: 18px;
cursor: pointer;
padding: 4px 8px;
color: #6b7280;
}
.pole-list__header-actions {
display: flex;
align-items: center;
gap: 6px;
}
.pole-list__upload {
padding: 4px 10px;
border-radius: 6px;
border: 1px solid #d1d5db;
background: white;
font-size: 12px;
font-weight: 600;
cursor: pointer;
color: #374151;
white-space: nowrap;
}
.pole-list__upload:hover {
background-color: #f3f4f6;
}
.pole-list__scroll {
overflow-y: auto;
flex: 1;
}
.pole-list__filters {
padding: 8px 12px;
border-bottom: 1px solid #e5e7eb;
display: flex;
gap: 6px;
flex-shrink: 0;
}
.pole-filter-btn {
padding: 4px 12px;
border-radius: 14px;
border: 1px solid #d1d5db;
background: white;
font-size: 12px;
font-weight: 600;
cursor: pointer;
color: #374151;
transition: background-color 0.15s, color 0.15s;
}
.pole-filter-btn--active {
border-color: transparent;
}
.pole-list__area-filter {
padding: 6px 12px;
border-bottom: 1px solid #e5e7eb;
flex-shrink: 0;
display: flex;
gap: 6px;
}
.pole-area-select {
flex: 1;
padding: 6px 10px;
border: 1px solid #d1d5db;
border-radius: 8px;
font-size: 13px;
color: #374151;
background: white;
cursor: pointer;
outline: none;
min-width: 0;
}
.pole-area-select:focus {
border-color: #6366f1;
}
.pole-item__level {
display: inline-block;
padding: 1px 6px;
border-radius: 4px;
color: white;
font-size: 10px;
font-weight: 700;
margin-right: 6px;
vertical-align: middle;
}
.pole-item {
display: flex;
align-items: center;
padding: 10px 12px;
border-bottom: 1px solid #f3f4f6;
gap: 10px;
cursor: pointer;
}
.pole-item__thumb {
width: 48px;
height: 48px;
border-radius: 6px;
object-fit: cover;
flex-shrink: 0;
}
.pole-item__info {
flex: 1;
min-width: 0;
}
.pole-item__coords {
font-size: 12px;
color: #374151;
font-weight: 500;
}
.pole-item__time {
font-size: 11px;
color: #9ca3af;
margin-top: 2px;
}
.pole-item__delete {
background: none;
border: none;
font-size: 16px;
cursor: pointer;
padding: 6px;
color: #ef4444;
flex-shrink: 0;
}
.map-popup {
position: absolute;
background: white;
border-radius: 10px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
padding: 8px;
min-width: 180px;
max-width: 240px;
pointer-events: auto;
}
.map-popup:empty {
display: none;
}
.map-popup__close {
position: absolute;
top: 4px;
right: 4px;
width: 22px;
height: 22px;
border-radius: 50%;
border: none;
background: rgba(0, 0, 0, 0.45);
color: white;
font-size: 12px;
line-height: 22px;
text-align: center;
cursor: pointer;
padding: 0;
z-index: 1;
}
.map-popup__close:hover {
background: rgba(0, 0, 0, 0.7);
}
.map-popup__img {
width: 100%;
border-radius: 6px;
display: block;
object-fit: cover;
max-height: 160px;
}
.map-popup__info {
margin-top: 6px;
font-size: 11px;
color: #6b7280;
line-height: 1.4;
}
.map-popup__addr {
margin-left: 4px;
}
@media (min-width: 900px) {
.list-toggle,
.backdrop,
.pole-list__close {
display: none;
}
.gps-info {
top: 10px;
left: 10px;
right: auto;
}
.pole-list,
.pole-list--open,
.pole-list--closed {
top: 0;
right: 0;
width: 360px;
max-height: 100vh;
border-radius: 0;
box-shadow: -2px 0 12px rgba(0, 0, 0, 0.15);
opacity: 1;
pointer-events: auto;
}
.capture-button {
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}
.pole-item:hover {
background-color: #f9fafb;
}
}
+734
View File
@@ -0,0 +1,734 @@
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import Map from 'ol/Map';
import View from 'ol/View';
import Overlay from 'ol/Overlay';
import TileLayer from 'ol/layer/Tile';
import XYZ from 'ol/source/XYZ';
import VectorLayer from 'ol/layer/Vector';
import VectorSource from 'ol/source/Vector';
import Feature from 'ol/Feature';
import Point from 'ol/geom/Point';
import { Style, Circle as CircleStyle, Fill, Stroke, Text } from 'ol/style';
import { fromLonLat } from 'ol/proj';
import imageCompression from 'browser-image-compression';
import exifr from 'exifr';
import './App.css';
const VWORLD_API_KEY = '2C00322C-5037-37EB-A547-7001C13840E9';
const LEVEL_COLORS = { A: '#22c55e', B: '#f97316', Pole: '#a855f7' };
const LEVEL_LABELS = { A: 'A', B: 'B', Pole: 'P' };
function createTileSource(layer) {
return new XYZ({
url: `https://api.vworld.kr/req/wmts/1.0.0/${VWORLD_API_KEY}/${layer}/{z}/{y}/{x}.png`,
crossOrigin: null,
maxZoom: 19,
minZoom: 6,
});
}
function App() {
const mapContainerRef = useRef(null);
const mapRef = useRef(null);
const markerLayerRef = useRef(null);
const lastPositionRef = useRef(null);
const watchIdRef = useRef(null);
const fallbackUsedRef = useRef(false);
const currentLocationRef = useRef(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
const [poles, setPoles] = useState([]);
const [processing, setProcessing] = useState(false);
const [gpsInfo, setGpsInfo] = useState(null);
const [listOpen, setListOpen] = useState(false);
const [uploadProgress, setUploadProgress] = useState(null);
const folderInputRef = useRef(null);
const [levelFilter, setLevelFilter] = useState('all');
const [guFilter, setGuFilter] = useState('용산구');
const [dongFilter, setDongFilter] = useState('all');
const polesRef = useRef([]);
const [allDongs, setAllDongs] = useState([]);
const popupRef = useRef(null);
const popupOverlayRef = useRef(null);
const [popupPole, setPopupPole] = useState(null);
const guList = useMemo(() => {
const set = new Set(allDongs.map((d) => d.gu_name));
return [...set].sort();
}, [allDongs]);
const dongList = useMemo(() => {
if (guFilter === 'all') return allDongs;
return allDongs.filter((d) => d.gu_name === guFilter);
}, [allDongs, guFilter]);
const filteredPoles = useMemo(() => {
return poles.filter(
(p) => (levelFilter === 'all' || p.level === levelFilter) &&
(guFilter === 'all' || p.dong.includes(guFilter)) &&
(dongFilter === 'all' || p.dong.includes(dongFilter))
);
}, [poles, levelFilter, guFilter, dongFilter]);
useEffect(() => {
if (!gpsInfo) return;
const timer = setTimeout(() => setGpsInfo(null), 3000);
return () => clearTimeout(timer);
}, [gpsInfo]);
const syncMarkers = useCallback(() => {
if (!markerLayerRef.current) return;
const source = markerLayerRef.current.getSource();
source.getFeatures().forEach((f) => {
if (f.get('poleId') !== 'current-location') source.removeFeature(f);
});
const idSet = new Set();
polesRef.current.forEach((pole) => {
if (idSet.has(pole.id)) return;
if (levelFilter !== 'all' && pole.level !== levelFilter) return;
if (guFilter !== 'all' && !pole.dong.includes(guFilter)) return;
if (dongFilter !== 'all' && !pole.dong.includes(dongFilter)) return;
idSet.add(pole.id);
const feature = new Feature({
geometry: new Point(fromLonLat([pole.lng, pole.lat])),
poleId: pole.id,
});
feature.setStyle(
new Style({
image: new CircleStyle({
radius: 8,
fill: new Fill({ color: LEVEL_COLORS[pole.level] || '#ef4444' }),
stroke: new Stroke({ color: 'white', width: 2 }),
}),
text: new Text({
text: LEVEL_LABELS[pole.level] || '전신주',
offsetY: -20,
font: 'bold 12px sans-serif',
fill: new Fill({ color: '#1e293b' }),
stroke: new Stroke({ color: 'white', width: 3 }),
}),
}),
);
source.addFeature(feature);
});
}, [levelFilter, guFilter, dongFilter]);
useEffect(() => {
syncMarkers();
}, [syncMarkers]);
const addMarker = useCallback((lng, lat, id, level) => {
if (!markerLayerRef.current) return;
const isCurrentLocation = id === 'current-location';
const color = isCurrentLocation ? '#3b82f6' : (LEVEL_COLORS[level] || '#ef4444');
const label = isCurrentLocation ? '' : (LEVEL_LABELS[level] || '전신주');
const feature = new Feature({
geometry: new Point(fromLonLat([lng, lat])),
poleId: id,
});
feature.setStyle(
new Style({
image: new CircleStyle({
radius: isCurrentLocation ? 6 : 8,
fill: new Fill({ color }),
stroke: new Stroke({ color: 'white', width: 2 }),
}),
text: new Text({
text: label,
offsetY: -20,
font: 'bold 12px sans-serif',
fill: new Fill({ color: '#1e293b' }),
stroke: new Stroke({ color: 'white', width: 3 }),
}),
}),
);
markerLayerRef.current.getSource().addFeature(feature);
if (isCurrentLocation) {
currentLocationRef.current = feature;
}
}, []);
const handleDelete = useCallback(async (id) => {
try {
const res = await fetch(`/api/poles/${id}`, { method: 'DELETE' });
if (!res.ok) throw new Error(`삭제 실패 (HTTP ${res.status})`);
setPoles((prev) => {
polesRef.current = prev.filter((p) => p.id !== id);
return prev.filter((p) => p.id !== id);
});
} catch (err) {
console.error('전신주 삭제 실패:', err);
alert('전신주 삭제에 실패했습니다.');
}
}, []);
const flyTo = useCallback((lng, lat) => {
if (!mapRef.current) return;
mapRef.current.getView().animate({
center: fromLonLat([lng, lat]),
zoom: 18,
duration: 500,
});
}, []);
const flyToCurrentLocation = useCallback(() => {
const pos = lastPositionRef.current;
if (!pos || !mapRef.current) return;
mapRef.current.getView().animate({
center: fromLonLat([pos.lng, pos.lat]),
zoom: 17,
duration: 500,
});
}, []);
useEffect(() => {
if (mapRef.current) return;
let aborted = false;
const initMap = (lng, lat) => {
if (aborted || mapRef.current) return;
try {
const markerSource = new VectorSource();
const markerLayer = new VectorLayer({ source: markerSource });
markerLayerRef.current = markerLayer;
const map = new Map({
target: mapContainerRef.current,
layers: [
new TileLayer({ source: createTileSource('Base') }),
new TileLayer({ source: createTileSource('Hybrid') }),
markerLayer,
],
view: new View({
center: fromLonLat([lng, lat]),
zoom: 17,
maxZoom: 19,
minZoom: 6,
}),
});
mapRef.current = map;
const popupOverlay = new Overlay({
element: popupRef.current,
autoPan: { animation: { duration: 200 } },
});
map.addOverlay(popupOverlay);
popupOverlayRef.current = popupOverlay;
map.on('singleclick', (evt) => {
const feature = map.forEachFeatureAtPixel(evt.pixel, (f) => f);
if (!feature || feature.get('poleId') === 'current-location') {
setPopupPole(null);
popupOverlay.setPosition(undefined);
return;
}
const poleId = feature.get('poleId');
const pole = polesRef.current.find((p) => p.id === poleId);
if (!pole) return;
setPopupPole(pole);
popupOverlay.setPosition(evt.coordinate);
});
addMarker(lng, lat, 'current-location');
Promise.allSettled([
fetch('/api/poles').then((r) => { if (!r.ok) throw new Error(`HTTP ${r.status}`); return r.json(); }),
fetch('/api/all-dongs').then((r) => { if (!r.ok) throw new Error(`HTTP ${r.status}`); return r.json(); }),
])
.then(([poleResult, dongResult]) => {
if (aborted) return;
if (poleResult.status === 'fulfilled') {
polesRef.current = poleResult.value;
setPoles(poleResult.value);
}
if (dongResult.status === 'fulfilled') {
setAllDongs(dongResult.value);
}
})
.catch((err) => {
console.error('전신주 목록 불러오기 실패:', err);
})
.finally(() => {
if (!aborted) setLoading(false);
});
} catch (e) {
console.error('지도 초기화 실패:', e);
setError('지도를 불러오지 못했습니다.');
setLoading(false);
}
};
const handleSuccess = (position) => {
if (aborted) return;
const { latitude: lat, longitude: lng } = position.coords;
lastPositionRef.current = { lat, lng };
initMap(lng, lat);
};
const handleError = (err) => {
if (aborted) return;
console.error('getCurrentPosition 실패:', err?.code, err?.message);
const fallback = { lat: 37.5665, lng: 126.978 };
lastPositionRef.current = fallback;
fallbackUsedRef.current = true;
initMap(fallback.lng, fallback.lat);
};
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(handleSuccess, handleError, {
enableHighAccuracy: true,
});
watchIdRef.current = navigator.geolocation.watchPosition(
(position) => {
const { latitude: lat, longitude: lng } = position.coords;
lastPositionRef.current = { lat, lng };
if (currentLocationRef.current) {
currentLocationRef.current.getGeometry().setCoordinates(fromLonLat([lng, lat]));
}
if (fallbackUsedRef.current) {
fallbackUsedRef.current = false;
mapRef.current?.getView().animate({
center: fromLonLat([lng, lat]),
zoom: 17,
duration: 500,
});
}
},
(err) => {
console.error('watchPosition 실패:', err.code, err.message);
},
{ enableHighAccuracy: true, maximumAge: 10000 },
);
} else {
handleError();
}
return () => {
aborted = true;
if (watchIdRef.current != null) {
navigator.geolocation.clearWatch(watchIdRef.current);
watchIdRef.current = null;
}
if (mapRef.current) {
mapRef.current.setTarget(undefined);
mapRef.current = null;
}
markerLayerRef.current = null;
currentLocationRef.current = null;
fallbackUsedRef.current = false;
};
}, [addMarker]);
const handleCapture = async (e) => {
const file = e.target.files?.[0];
if (!file || processing) return;
setProcessing(true);
setGpsInfo(null);
try {
let lat;
let lng;
let source = '';
// 1차: 사진 EXIF에서 GPS 추출 (ArrayBuffer로 읽어 Android 호환성 확보)
try {
const buffer = await file.arrayBuffer();
console.log('파일 타입:', file.type, '크기:', file.size, 'buffer 크기:', buffer.byteLength);
const exifData = await exifr.parse(buffer);
console.log('EXIF 전체 데이터:', exifData);
if (exifData && exifData.latitude && exifData.longitude) {
lat = exifData.latitude;
lng = exifData.longitude;
source = 'EXIF';
lastPositionRef.current = { lat, lng };
} else {
console.log('EXIF에 GPS 데이터 없음');
}
} catch (err) {
console.error('EXIF 읽기 실패:', err);
}
// 2차: 브라우저 GPS (EXIF에 GPS가 없는 경우)
if (lat === undefined && navigator.geolocation) {
try {
console.log('브라우저 GPS 요청 중...');
const pos = await new Promise((resolve, reject) => {
navigator.geolocation.getCurrentPosition(resolve, reject, {
enableHighAccuracy: true,
timeout: 15000,
maximumAge: 30000,
});
});
lat = pos.coords.latitude;
lng = pos.coords.longitude;
source = '브라우저 GPS';
lastPositionRef.current = { lat, lng };
} catch (err) {
console.error('브라우저 GPS 실패:', err);
}
}
// 3차: 마지막 알려진 위치 (watchPosition 또는 초기 위치)
if (lat === undefined) {
const last = lastPositionRef.current;
if (last) {
lat = last.lat;
lng = last.lng;
source = watchIdRef.current != null ? '실시간 GPS' : '폴백 (초기 위치)';
} else {
throw new Error('No GPS available');
}
}
setGpsInfo({ source, lat, lng });
const compressed = await imageCompression(file, {
maxSizeMB: 0.5,
maxWidthOrHeight: 800,
useWebWorker: true,
});
const id = `pole-${Date.now()}`;
const formData = new FormData();
formData.append('photo', compressed, `${id}.jpg`);
formData.append('id', id);
formData.append('lat', lat);
formData.append('lng', lng);
formData.append('timestamp', new Date().toISOString());
const res = await fetch('/api/poles', { method: 'POST', body: formData });
if (!res.ok) throw new Error(`등록 실패 (HTTP ${res.status})`);
const pole = await res.json();
setPoles((prev) => {
polesRef.current = [...prev, pole];
return [...prev, pole];
});
} catch (err) {
console.error('전신주 등록 실패:', err);
alert('전신주 등록에 실패했습니다. 위치 정보를 가져올 수 없습니다.');
} finally {
setProcessing(false);
e.target.value = '';
}
};
const handleFolderUpload = async (e) => {
const files = Array.from(e.target.files || []);
const imageFiles = files.filter((f) =>
f.type.startsWith('image/') || /\.(jpe?g|png|heic|webp|bmp|gif)$/i.test(f.name)
);
if (imageFiles.length === 0) {
alert('이미지 파일이 없습니다.');
e.target.value = '';
return;
}
setProcessing(true);
setUploadProgress({ current: 0, total: imageFiles.length });
let registered = 0;
let skipped = 0;
for (let i = 0; i < imageFiles.length; i++) {
const file = imageFiles[i];
setUploadProgress({ current: i + 1, total: imageFiles.length });
try {
let lat;
let lng;
try {
const buffer = await file.arrayBuffer();
const exifData = await exifr.parse(buffer);
if (exifData && exifData.latitude && exifData.longitude) {
lat = exifData.latitude;
lng = exifData.longitude;
lastPositionRef.current = { lat, lng };
}
} catch (err) {
console.error('EXIF 읽기 실패:', file.name, err);
}
if (lat === undefined) {
skipped++;
continue;
}
const compressed = await imageCompression(file, {
maxSizeMB: 0.5,
maxWidthOrHeight: 800,
useWebWorker: true,
});
const id = `pole-${Date.now()}-${i}`;
const formData = new FormData();
formData.append('photo', compressed, `${id}.jpg`);
formData.append('id', id);
formData.append('lat', lat);
formData.append('lng', lng);
formData.append('timestamp', new Date().toISOString());
const res = await fetch('/api/poles', { method: 'POST', body: formData });
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const pole = await res.json();
setPoles((prev) => {
polesRef.current = [...prev, pole];
return [...prev, pole];
});
registered++;
} catch (err) {
console.error('전신주 등록 실패:', file.name, err);
skipped++;
}
}
setUploadProgress(null);
setProcessing(false);
alert(`등록 완료: ${registered}장${skipped > 0 ? ` / 건너뜀: ${skipped}장 (GPS 없음)` : ''}`);
e.target.value = '';
};
return (
<main className="app">
<div ref={mapContainerRef} className="map-container" />
<div ref={popupRef} className="map-popup">
{popupPole && (
<>
<button
type="button"
className="map-popup__close"
onClick={() => {
setPopupPole(null);
popupOverlayRef.current?.setPosition(undefined);
}}
>
✕
</button>
<img src={popupPole.photoUrl} alt="전신주" className="map-popup__img" />
<div className="map-popup__info">
<span
className="pole-item__level"
style={{ backgroundColor: LEVEL_COLORS[popupPole.level] || '#94a3b8' }}
>
{LEVEL_LABELS[popupPole.level] || popupPole.level || '-'}
</span>
<span className="map-popup__addr">{popupPole.dong}</span>
</div>
</>
)}
</div>
{(loading || processing) && !uploadProgress && (
<div className="overlay">
{loading ? '지도 불러오는 중...' : '전신주 등록 중...'}
</div>
)}
{error && <div className="error-banner">{error}</div>}
<div className="capture-bar">
<input
type="file"
accept="image/*"
capture="environment"
id="camera-input"
className="camera-input"
onChange={handleCapture}
/>
<input
type="file"
accept="image/*"
webkitdirectory=""
id="folder-input"
className="camera-input"
ref={folderInputRef}
onChange={handleFolderUpload}
/>
<label htmlFor="camera-input" className="capture-button">
📷 등록
</label>
<button
type="button"
className="locate-btn"
onClick={flyToCurrentLocation}
>
📍
</button>
</div>
{uploadProgress && (
<div className="upload-progress">
{uploadProgress.current}/{uploadProgress.total} 업로드 중...
</div>
)}
{poles.length > 0 && (
<button
type="button"
onClick={() => setListOpen((o) => !o)}
className="list-toggle"
>
📋 {filteredPoles.length}기
</button>
)}
{gpsInfo && (
<div
className={
gpsInfo.source === '폴백 (초기 위치)'
? 'gps-info gps-info--fallback'
: 'gps-info gps-info--normal'
}
>
<div className="gps-info__title">📍 {gpsInfo.source}</div>
<div>{gpsInfo.lat.toFixed(5)}, {gpsInfo.lng.toFixed(5)}</div>
</div>
)}
{listOpen && (
<div
className="backdrop"
onClick={() => setListOpen(false)}
onKeyDown={() => setListOpen(false)}
role="button"
tabIndex={0}
/>
)}
<div
className={listOpen ? 'pole-list pole-list--open' : 'pole-list pole-list--closed'}
>
<div className="pole-list__header">
<span className="pole-list__title">
전신주 목록 ({filteredPoles.length}기)
</span>
<div className="pole-list__header-actions">
<button
type="button"
className="pole-list__upload"
onClick={() => document.getElementById('folder-input').click()}
>
📁 폴더 업로드
</button>
<button
type="button"
onClick={() => setListOpen(false)}
className="pole-list__close"
>
✕
</button>
</div>
</div>
<div className="pole-list__filters">
{[
{ value: 'all', label: '전체', color: '#94a3b8' },
{ value: 'A', label: 'A', color: LEVEL_COLORS.A },
{ value: 'B', label: 'B', color: LEVEL_COLORS.B },
{ value: 'Pole', label: 'Pole', color: LEVEL_COLORS.Pole },
].map((f) => (
<button
key={f.value}
type="button"
className={`pole-filter-btn ${levelFilter === f.value ? 'pole-filter-btn--active' : ''}`}
style={levelFilter === f.value ? { backgroundColor: f.color, color: 'white' } : {}}
onClick={() => setLevelFilter(f.value)}
>
{f.label}
</button>
))}
</div>
<div className="pole-list__area-filter">
<select
className="pole-area-select"
value={guFilter}
onChange={(e) => {
setGuFilter(e.target.value);
setDongFilter('all');
}}
>
<option value="all">전체 구</option>
{guList.map((gu) => {
const count = poles.filter((p) => p.dong.includes(gu)).length;
return (
<option key={gu} value={gu}>{gu} ({count}기)</option>
);
})}
</select>
<select
className="pole-area-select"
value={dongFilter}
onChange={(e) => setDongFilter(e.target.value)}
>
<option value="all">전체 동</option>
{dongList.map((d) => {
const count = poles.filter((p) => p.dong.includes(d.dong)).length;
return (
<option key={d.dong} value={d.dong}>{d.dong} ({count}기)</option>
);
})}
</select>
</div>
<div className="pole-list__scroll">
{[...filteredPoles].reverse().map((pole) => (
<div
key={pole.id}
className="pole-item"
onClick={() => {
flyTo(pole.lng, pole.lat);
setListOpen(false);
}}
onKeyDown={() => {
flyTo(pole.lng, pole.lat);
setListOpen(false);
}}
role="button"
tabIndex={0}
>
<img src={pole.photoUrl} alt="전신주" className="pole-item__thumb" />
<div className="pole-item__info">
<div className="pole-item__coords">
<span
className="pole-item__level"
style={{ backgroundColor: LEVEL_COLORS[pole.level] || '#94a3b8' }}
>
{LEVEL_LABELS[pole.level] || pole.level || '-'}
</span>
{pole.lat.toFixed(5)}, {pole.lng.toFixed(5)}
</div>
<div className="pole-item__time">
{new Date(pole.timestamp).toLocaleString('ko-KR')}
</div>
</div>
<button
type="button"
onClick={(e) => {
e.stopPropagation();
handleDelete(pole.id);
}}
className="pole-item__delete"
>
🗑
</button>
</div>
))}
</div>
</div>
</main>
);
}
export default App;
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>

After

Width:  |  Height:  |  Size: 4.0 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 8.5 KiB

+16
View File
@@ -0,0 +1,16 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: system-ui, -apple-system, sans-serif;
overflow: hidden;
padding-bottom: env(safe-area-inset-bottom, 0px);
}
#root {
width: 100vw;
height: 100vh;
}
+10
View File
@@ -0,0 +1,10 @@
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.jsx'
createRoot(document.getElementById('root')).render(
<StrictMode>
<App />
</StrictMode>
);