Skip to content

Commit 1fc569f

Browse files
committed
Work in progress
Добавил MKUserTrackingButton на карту, чтобы центрировать карту на положении пользователя
1 parent a173d00 commit 1fc569f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

SwiftUI-WorkoutApp/Screens/SportsGrounds/Map/MapViewUI.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ struct MapViewUI: UIViewRepresentable {
3838
mapView.setRegion(region, animated: true)
3939
mapView.showsUserLocation = true
4040
mapView.isRotateEnabled = false
41+
let trackingButton = MKUserTrackingButton(mapView: mapView)
42+
trackingButton.translatesAutoresizingMaskIntoConstraints = false
43+
mapView.addSubview(trackingButton)
44+
NSLayoutConstraint.activate([
45+
trackingButton.topAnchor.constraint(
46+
equalTo: mapView.layoutMarginsGuide.topAnchor,
47+
constant: 60
48+
),
49+
trackingButton.trailingAnchor.constraint(
50+
equalTo: mapView.layoutMarginsGuide.trailingAnchor,
51+
constant: -8
52+
)
53+
])
4154
mapView.cameraZoomRange = .init(maxCenterCoordinateDistance: 500000)
4255
return mapView
4356
}

0 commit comments

Comments
 (0)