Skip to content

Commit b7a3be0

Browse files
committed
Update SetViewpointRotationView.swift
1 parent 74259cd commit b7a3be0

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

Shared/Samples/Set viewpoint rotation/SetViewpointRotationView.swift

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,19 @@ struct SetViewpointRotationView: View {
3131

3232
var body: some View {
3333
VStack {
34-
MapView(map: map, viewpoint: Viewpoint(center: center, scale: scale, rotation: rotation))
35-
.onViewpointChanged(kind: .centerAndScale) { viewpoint in
36-
center = viewpoint.targetGeometry.extent.center
37-
scale = viewpoint.targetScale
38-
rotation = viewpoint.rotation
39-
}
40-
.overlay(alignment: .topTrailing) {
41-
Compass(viewpointRotation: $rotation)
42-
.autoHideDisabled()
43-
.padding()
44-
}
34+
MapViewReader { mapViewProxy in
35+
MapView(map: map, viewpoint: Viewpoint(center: center, scale: scale, rotation: rotation))
36+
.onViewpointChanged(kind: .centerAndScale) { viewpoint in
37+
center = viewpoint.targetGeometry.extent.center
38+
scale = viewpoint.targetScale
39+
rotation = viewpoint.rotation
40+
}
41+
.overlay(alignment: .topTrailing) {
42+
Compass(rotation: rotation, mapViewProxy: mapViewProxy)
43+
.autoHideDisabled()
44+
.padding()
45+
}
46+
}
4547

4648
HStack {
4749
// Create a slider to rotate the map.

0 commit comments

Comments
 (0)