Skip to content

Commit 688a78f

Browse files
committed
[#234] 지도의 시작 위치를 숭실대학교로 지정
1 parent 6c2c221 commit 688a78f

File tree

10 files changed

+233
-24
lines changed

10 files changed

+233
-24
lines changed

EATSSU/App/Sources/Presentation/Maps/ViewController/MapViewController.swift

+79-23
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,35 @@
55
// Created by JIWOONG CHOI on 1/28/25.
66
//
77

8-
import UIKit
9-
108
import EATSSUDesign
11-
129
import NMapsMap
10+
import UIKit
1311

12+
/// `MapViewController`는 네이버 지도를 표시하고, 마커를 추가하는 역할을 합니다.
1413
final class MapViewController: BaseViewController, NMFMapViewTouchDelegate {
14+
/// 네이버 지도 뷰
1515
private var mapView: NMFMapView!
1616

17+
/// 숭실대학교 위치 (위도, 경도)
18+
private let soongsilUniversityLocation = NMGLatLng(lat: 37.496389, lng: 126.957222)
19+
20+
// MARK: - Life Cycle
21+
1722
override func viewDidLoad() {
1823
super.viewDidLoad()
19-
setNavigationBar()
20-
21-
mapView = NMFMapView(frame: view.frame)
22-
view.addSubview(mapView)
24+
setupUI()
25+
configureMapView()
26+
addSoongsilMarker()
27+
}
2328

24-
// Sample marker at NAVER 1984 location
25-
let sampleMarker = ESMarker(
26-
position: NMGLatLng(lat: 37.3595704, lng: 127.105399),
27-
data: "Sample Data",
28-
leftText: "NAVER",
29-
rightText: "1984"
30-
)
31-
sampleMarker.marker.mapView = mapView
29+
// MARK: - UI 설정
3230

33-
mapView.touchDelegate = self
31+
/// UI를 초기화하고 네비게이션 바를 설정합니다.
32+
private func setupUI() {
33+
setNavigationBar()
3434
}
3535

36+
/// 네비게이션 바 스타일을 설정합니다.
3637
private func setNavigationBar() {
3738
navigationItem.title = ESTextLiteral.Map.mapNavTitle
3839
navigationController?.isNavigationBarHidden = false
@@ -47,26 +48,81 @@ final class MapViewController: BaseViewController, NMFMapViewTouchDelegate {
4748
navigationController?.navigationBar.standardAppearance = appearance
4849
navigationController?.navigationBar.scrollEdgeAppearance = appearance
4950
}
51+
52+
// MARK: - 지도 설정
53+
54+
/// 네이버 지도 뷰를 초기화하고 화면에 추가합니다.
55+
private func configureMapView() {
56+
mapView = NMFMapView(frame: view.frame)
57+
view.addSubview(mapView)
58+
mapView.touchDelegate = self
59+
60+
moveCamera(to: soongsilUniversityLocation, zoomLevel: 16.0)
61+
}
62+
63+
/// 카메라를 특정 위치로 이동합니다.
64+
/// - Parameters:
65+
/// - location: 이동할 위치의 위도 및 경도 (`NMGLatLng`)
66+
/// - zoomLevel: 줌 레벨 (`Double`)
67+
private func moveCamera(to location: NMGLatLng, zoomLevel: Double) {
68+
let cameraUpdate = NMFCameraUpdate(
69+
position: NMFCameraPosition(location, zoom: zoomLevel)
70+
)
71+
mapView.moveCamera(cameraUpdate)
72+
}
73+
74+
// MARK: - 마커 설정
75+
76+
/// 숭실대학교 위치에 마커를 추가합니다.
77+
private func addSoongsilMarker() {
78+
let soongsilMarker = ESMarker(
79+
position: soongsilUniversityLocation,
80+
data: "Soongsil Univ",
81+
leftText: "숭실대학교",
82+
rightText: "Soongsil Univ"
83+
)
84+
soongsilMarker.marker.mapView = mapView
85+
}
5086
}
5187

88+
// MARK: - NMFMapViewTouchDelegate (지도 터치 이벤트)
89+
5290
extension MapViewController {
91+
/// 사용자가 지도에서 단일 탭을 했을 때 호출됩니다.
92+
/// - Parameters:
93+
/// - latlng: 사용자가 탭한 위치 (`NMGLatLng`)
94+
/// - point: 터치된 화면 좌표 (`CGPoint`)
5395
func mapView(_: NMFMapView, didTapMap latlng: NMGLatLng, point _: CGPoint) {
5496
#if DEBUG
5597
print("탭: \(latlng.lat), \(latlng.lng)")
5698
#endif
5799

58-
let marker = ESMarker(
59-
position: NMGLatLng(lat: latlng.lat, lng: latlng.lng),
60-
data: "Tapped Location",
61-
leftText: "Tapped Marker",
62-
rightText: "Here is the location"
63-
)
64-
marker.marker.mapView = mapView
100+
addMarker(at: latlng, title: "Tapped Location", leftText: "Tapped Marker", rightText: "Here is the location")
65101
}
66102

103+
/// 사용자가 지도에서 길게 눌렀을 때 호출됩니다.
104+
/// - Parameters:
105+
/// - latlng: 사용자가 길게 누른 위치 (`NMGLatLng`)
106+
/// - point: 터치된 화면 좌표 (`CGPoint`)
67107
func mapView(_: NMFMapView, didLongTapMap latlng: NMGLatLng, point _: CGPoint) {
68108
#if DEBUG
69109
print("롱 탭: \(latlng.lat), \(latlng.lng)")
70110
#endif
71111
}
112+
113+
/// 특정 위치에 마커를 추가합니다.
114+
/// - Parameters:
115+
/// - location: 마커를 추가할 위치 (`NMGLatLng`)
116+
/// - title: 마커의 데이터 (`String`)
117+
/// - leftText: 마커 왼쪽 텍스트 (`String`)
118+
/// - rightText: 마커 오른쪽 텍스트 (`String`)
119+
private func addMarker(at location: NMGLatLng, title: String, leftText: String, rightText: String) {
120+
let marker = ESMarker(
121+
position: location,
122+
data: title,
123+
leftText: leftText,
124+
rightText: rightText
125+
)
126+
marker.marker.mapView = mapView
127+
}
72128
}

EATSSUDesign/EATSSUDesign/Sources/BrandDesignComponents/ESMarker/ESMarker.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public final class ESMarker {
2727
private enum Layout {
2828
static let horizontalPadding: CGFloat = 12 // 텍스트와 말풍선 가장자리 간격
2929
static let verticalPadding: CGFloat = 8 // 텍스트와 말풍선 위아래 간격
30-
static let spacing: CGFloat = 5 // 왼쪽 말풍선과 오른쪽 말풍선 간격
30+
static let spacing: CGFloat = 0 // 왼쪽 말풍선과 오른쪽 말풍선 간격
3131
static let cornerRadius: CGFloat = 25 // 말풍선의 둥근 정도
3232
static let leftBubblePadding: CGFloat = 5 // 왼쪽 말풍선의 추가 패딩
3333
static let tailHeight: CGFloat = 10 // 말풍선 꼬리의 높이

EATSSUKit/.gitignore

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
### macOS ###
2+
# General
3+
.DS_Store
4+
.AppleDouble
5+
.LSOverride
6+
7+
# Icon must end with two
8+
Icon
9+
10+
# Thumbnails
11+
._*
12+
13+
# Files that might appear in the root of a volume
14+
.DocumentRevisions-V100
15+
.fseventsd
16+
.Spotlight-V100
17+
.TemporaryItems
18+
.Trashes
19+
.VolumeIcon.icns
20+
.com.apple.timemachine.donotpresent
21+
22+
# Directories potentially created on remote AFP share
23+
.AppleDB
24+
.AppleDesktop
25+
Network Trash Folder
26+
Temporary Items
27+
.apdisk
28+
29+
### Xcode ###
30+
# Xcode
31+
#
32+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
33+
34+
## User settings
35+
xcuserdata/
36+
37+
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
38+
*.xcscmblueprint
39+
*.xccheckout
40+
41+
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
42+
build/
43+
DerivedData/
44+
*.moved-aside
45+
*.pbxuser
46+
!default.pbxuser
47+
*.mode1v3
48+
!default.mode1v3
49+
*.mode2v3
50+
!default.mode2v3
51+
*.perspectivev3
52+
!default.perspectivev3
53+
54+
### Xcode Patch ###
55+
*.xcodeproj/*
56+
!*.xcodeproj/project.pbxproj
57+
!*.xcodeproj/xcshareddata/
58+
!*.xcworkspace/contents.xcworkspacedata
59+
/*.gcno
60+
61+
### Projects ###
62+
*.xcodeproj
63+
*.xcworkspace
64+
65+
### Tuist derived files ###
66+
graph.dot
67+
Derived/
68+
69+
### Tuist managed dependencies ###
70+
Tuist/.build
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//
2+
// Temp.swift
3+
// EATSSUKit
4+
//
5+
// Created by JIWOONG CHOI on 1/31/25.
6+
//
7+
8+
import Foundation
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Foundation
2+
import XCTest
3+
4+
final class EATSSUKitTests: XCTestCase {
5+
func test_twoPlusTwo_isFour() {
6+
XCTAssertEqual(2 + 2, 4)
7+
}
8+
}

EATSSUKit/Project.swift

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import ProjectDescription
2+
3+
let project = Project(
4+
name: "EATSSUKit",
5+
targets: [
6+
.target(
7+
name: "EATSSUKit",
8+
destinations: .iOS,
9+
product: .framework,
10+
bundleId: "com.EATSSU.EATSSUKit",
11+
infoPlist: .extendingDefault(
12+
with: [
13+
"UILaunchScreen": [
14+
"UIColorName": "",
15+
"UIImageName": "",
16+
],
17+
]
18+
),
19+
sources: ["EATSSUKit/Sources/**"],
20+
dependencies: []
21+
),
22+
.target(
23+
name: "EATSSUKitTests",
24+
destinations: .iOS,
25+
product: .unitTests,
26+
bundleId: "com.EATSSU.EATSSUKitTests",
27+
infoPlist: .default,
28+
sources: ["EATSSUKit/Tests/**"],
29+
resources: [],
30+
dependencies: [.target(name: "EATSSUKit")]
31+
),
32+
]
33+
)

EATSSUKit/Tuist.swift

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import ProjectDescription
2+
3+
let tuist = Tuist(
4+
// Create an account with "tuist auth" and a project with "tuist project create"
5+
// then uncomment the section below and set the project full-handle.
6+
// * Read more: https://docs.tuist.io/guides/quick-start/gather-insights
7+
//
8+
// fullHandle: "{account_handle}/{project_handle}",
9+
)

EATSSUKit/Tuist/Package.swift

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// swift-tools-version: 6.0
2+
import PackageDescription
3+
4+
#if TUIST
5+
import struct ProjectDescription.PackageSettings
6+
7+
let packageSettings = PackageSettings(
8+
// Customize the product types for specific package product
9+
// Default is .staticFramework
10+
// productTypes: ["Alamofire": .framework,]
11+
productTypes: [:]
12+
)
13+
#endif
14+
15+
let package = Package(
16+
name: "EATSSUKit",
17+
dependencies: [
18+
// Add your own dependencies here:
19+
// .package(url: "https://github.com/Alamofire/Alamofire", from: "5.0.0"),
20+
// You can read more about dependencies here: https://docs.tuist.io/documentation/tuist/dependencies
21+
]
22+
)

EATSSUKit/mise.toml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[tools]
2+
tuist = "x.y.z"

Workspace.swift

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ import ProjectDescription
33
let workspace = Workspace(name: "EATSSU_WORKSPACE", projects: [
44
"EATSSU",
55
"EATSSUDesign",
6+
"EATSSUKit",
67
])

0 commit comments

Comments
 (0)