-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
89 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+20.1 KB
...codeproj/project.xcworkspace/xcuserdata/evelyn.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
14 changes: 14 additions & 0 deletions
14
MC2Maps.xcodeproj/xcuserdata/evelyn.xcuserdatad/xcschemes/xcschememanagement.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>SchemeUserState</key> | ||
<dict> | ||
<key>MC2Maps.xcscheme_^#shared#^_</key> | ||
<dict> | ||
<key>orderHint</key> | ||
<integer>0</integer> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// Maplocation.swift | ||
// MC2Maps | ||
// | ||
// Created by Evelyn Hong on 8/15/24. | ||
// | ||
|
||
import SwiftUI | ||
import CoreLocation | ||
|
||
final class GeoServiceManager: NSObject, CLLocationManagerDelegate { | ||
private var locationManager: CLLocationManager! | ||
|
||
override init() { | ||
super.init() | ||
locationManager = CLLocationManager() | ||
locationManager.delegate = self | ||
locationManager.desiredAccuracy = kCLLocationAccuracyBest | ||
locationManager.startUpdatingLocation() | ||
} | ||
|
||
// 좌표 -> 도로명 주소 | ||
func getRoadAddress(for location: CLLocation, completion: @escaping (String?) -> Void) { | ||
let geocoder = CLGeocoder() | ||
let locale = Locale(identifier: "Ko-kr") | ||
geocoder.reverseGeocodeLocation(location, preferredLocale: locale) { placeMarks, error in | ||
guard let placeMarks = placeMarks, | ||
let address = placeMarks.last, | ||
error == nil else { | ||
completion(nil) // 오류 발생 시 nil 반환 | ||
return | ||
} | ||
let country = address.country ?? "" | ||
let administrativeArea = address.administrativeArea ?? "" | ||
let locality = address.locality ?? "" | ||
let subLocality = address.subLocality ?? "" | ||
let subThoroughfare = address.subThoroughfare ?? "" | ||
let fullAddress = "\(country) \(administrativeArea) \(locality) \(subLocality) \(subThoroughfare)" | ||
|
||
|
||
DispatchQueue.main.async { | ||
completion(fullAddress) // 주소 문자열을 반환 | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters