Skip to content

Commit f1fd5b6

Browse files
author
Achyut Kumar M
committed
change from camera altitude to latitudeDelta
1 parent c7fe8ff commit f1fd5b6

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

GoInfoGame/GoInfoGame/Helpers/Extensions.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ extension View {
3131
}
3232

3333

34+
extension MKMapView {
35+
func isZoomedIn(maxLatitudeDelta: CLLocationDegrees = 0.005) -> Bool {
36+
return self.region.span.latitudeDelta <= maxLatitudeDelta
37+
}
38+
}
39+
3440
extension CLLocationCoordinate2D: CustomPersistable {
3541

3642
public static func == (lhs: CLLocationCoordinate2D, rhs: CLLocationCoordinate2D) -> Bool {

GoInfoGame/GoInfoGame/UI/Map/CustomMap.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ struct CustomMap: UIViewRepresentable {
139139

140140
let shadowOverlay: ShadowOverlay
141141

142-
private let maxZoomAltitude: CLLocationDistance = 100
142+
private let maxZoomAltitude: CLLocationDistance = 120
143143
private var zoomReachedLimit: Bool = false
144144

145145
init(_ parent: CustomMap, shadowOverlay: ShadowOverlay) {
@@ -274,6 +274,9 @@ struct CustomMap: UIViewRepresentable {
274274
mapView.showAnnotations(annotation.memberAnnotations, animated: true)
275275

276276
if zoomReachedLimit && annotation.memberAnnotations.count <= 3 {
277+
let firstAnnotation = annotation.memberAnnotations.first as! DisplayUnitAnnotation
278+
let secondAnnotation = annotation.memberAnnotations.last as! DisplayUnitAnnotation
279+
277280
if let annotation = annotation.memberAnnotations.first as? DisplayUnitAnnotation {
278281
selectedAnAnnotation(selectedQuest: annotation)
279282
}
@@ -350,12 +353,7 @@ struct CustomMap: UIViewRepresentable {
350353
}
351354

352355
func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) {
353-
let currentAltitude = mapView.camera.altitude
354-
if currentAltitude < maxZoomAltitude {
355-
zoomReachedLimit = true
356-
} else {
357-
zoomReachedLimit = false
358-
}
356+
zoomReachedLimit = mapView.isZoomedIn()
359357
}
360358

361359
private func selectedAnAnnotation(selectedQuest: DisplayUnitAnnotation) {

0 commit comments

Comments
 (0)