Skip to content

Commit 7eee96f

Browse files
committed
implemented focusing to user current location on selecting the workspace.
1 parent 9db9541 commit 7eee96f

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

GoInfoGame/GoInfoGame/UI/Map/CustomMap.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import ClusterMap
1515
// Custom Map for managing map interactions between SwiftUI and UIKit components
1616
struct CustomMap: UIViewRepresentable {
1717

18-
var region: MKCoordinateRegion
18+
@Binding var region: MKCoordinateRegion
1919
@Binding var trackingMode: MapUserTrackingMode
2020
@Binding var items: [DisplayUnitWithCoordinate]
2121
@Binding var selectedQuest: DisplayUnit?

GoInfoGame/GoInfoGame/UI/Map/MapView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct MapView: View {
7272
}
7373

7474

75-
CustomMap(region: viewModel.region,
75+
CustomMap(region: $viewModel.region,
7676
trackingMode: $trackingMode,
7777
items: $viewModel.items,
7878
selectedQuest: $viewModel.selectedQuest,

GoInfoGame/GoInfoGame/UI/Map/MapViewModel.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class MapViewModel: ObservableObject {
2323
@Published var isLoading: Bool = false
2424
// var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 37.3318, longitude: -122.0312), span: MKCoordinateSpan(latitudeDelta: 0.0009 , longitudeDelta: 0.0009))
2525
@Published var region = MKCoordinateRegion()
26-
let viewSpanDelta = 0.005 // Delta lat/lng to show to the user
26+
private let viewSpanDelta = 0.005 // Delta lat/lng to show to the user
2727
// var userlocation = CLLocationCoordinate2D(latitude: 17.4700, longitude: 78.3534)
2828
@Published var refreshMap = UUID()
2929
@Published var items: [DisplayUnitWithCoordinate] = []
@@ -47,12 +47,6 @@ class MapViewModel: ObservableObject {
4747
locationManagerDelegate.locationUpdateHandler = { [weak self] location in
4848
guard let self = self else { return }
4949

50-
DispatchQueue.main.async { [unowned self] in
51-
self.region = MKCoordinateRegion(
52-
center: location,
53-
span: MKCoordinateSpan(latitudeDelta: self.viewSpanDelta, longitudeDelta: self.viewSpanDelta)
54-
)
55-
}
5650
self.fetchOSMDataFor(from: .currentLocation(location: location))
5751
}
5852

0 commit comments

Comments
 (0)