Skip to content

Commit ac61f0d

Browse files
chore: Update Maps and Places samples from CocoaPods (#171)
* chore: Update Maps and Places samples from CocoaPods * chore: update snippets and tutorials to 8.0.0 --------- Co-authored-by: Angela Yu <[email protected]>
1 parent 683fb61 commit ac61f0d

File tree

33 files changed

+502
-417
lines changed

33 files changed

+502
-417
lines changed

GoogleMaps-Swift/GoogleMapsSwiftDemos.xcodeproj/project.pbxproj

Lines changed: 173 additions & 165 deletions
Large diffs are not rendered by default.
315 Bytes
Loading
3.27 KB
Loading

GoogleMaps-Swift/GoogleMapsSwiftDemos/Swift/SDKConstants.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ extension CLLocationCoordinate2D {
2424
// Victoria, Australia
2525
static let victoria = CLLocationCoordinate2D(latitude: -37.81969, longitude: 144.966085)
2626
static let newYork = CLLocationCoordinate2D(latitude: 40.761388, longitude: -73.978133)
27+
static let mountainSceneLocation = CLLocationCoordinate2D(
28+
latitude: -33.732022, longitude: 150.312114)
2729
}

GoogleMaps-Swift/GoogleMapsSwiftDemos/Swift/Samples/FixedPanoramaViewController.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ import GoogleMaps
1515
import UIKit
1616

1717
class FixedPanoramaViewController: UIViewController {
18-
1918
override func loadView() {
2019
let panoramaView = GMSPanoramaView(frame: .zero)
21-
panoramaView.moveNearCoordinate(.newYork)
20+
panoramaView.moveNearCoordinate(.mountainSceneLocation)
2221
panoramaView.camera = GMSPanoramaCamera(heading: 180, pitch: -10, zoom: 0)
2322
panoramaView.orientationGestures = false
2423
panoramaView.navigationGestures = false

GoogleMaps-Swift/Podfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
source 'https://github.com/CocoaPods/Specs.git'
22

33
target 'GoogleMapsSwiftDemos' do
4-
platform :ios, '13.0'
5-
pod 'GoogleMaps', '= 7.4.0'
4+
platform :ios, '14.0'
5+
pod 'GoogleMaps', '= 8.0.0'
66
end

GoogleMaps/GoogleMapsDemos.xcodeproj/project.pbxproj

Lines changed: 131 additions & 123 deletions
Large diffs are not rendered by default.
315 Bytes
Loading
3.27 KB
Loading

GoogleMaps/GoogleMapsDemos/Samples/MapLayerViewController.m

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
@implementation MapLayerViewController {
2121
GMSMapView *_mapView;
22+
BOOL _rotating;
2223
}
2324

2425
- (void)viewDidLoad {
@@ -47,43 +48,39 @@ - (void)didTapMyLocation {
4748
if (!location || !CLLocationCoordinate2DIsValid(location.coordinate)) {
4849
return;
4950
}
50-
51-
_mapView.layer.cameraLatitude = location.coordinate.latitude;
52-
_mapView.layer.cameraLongitude = location.coordinate.longitude;
53-
_mapView.layer.cameraBearing = 0.0;
54-
55-
// Access the GMSMapLayer directly to modify the following properties with a specified timing
56-
// function and duration.
51+
GMSCameraPosition *camera =
52+
[[GMSCameraPosition alloc] initWithTarget:location.coordinate
53+
zoom:_mapView.camera.zoom
54+
bearing:0.0
55+
viewingAngle:_mapView.camera.viewingAngle];
5756
CAMediaTimingFunction *curve =
5857
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
59-
CABasicAnimation *animation;
60-
61-
animation = [CABasicAnimation animationWithKeyPath:kGMSLayerCameraLatitudeKey];
62-
animation.duration = 2.0f;
63-
animation.timingFunction = curve;
64-
animation.toValue = @(location.coordinate.latitude);
65-
[_mapView.layer addAnimation:animation forKey:kGMSLayerCameraLatitudeKey];
58+
// Animate to the marker
59+
[CATransaction begin];
60+
[CATransaction setAnimationDuration:2.0f]; // 2 second animation
61+
[CATransaction setAnimationTimingFunction:curve];
62+
[CATransaction setCompletionBlock:^{
63+
if (_rotating) { // Animation was interrupted by orientation change.
64+
[CATransaction
65+
setDisableActions:true]; // Disable animation to avoid interruption from rotation.
66+
[_mapView animateToCameraPosition:camera];
67+
}
68+
}];
6669

67-
animation = [CABasicAnimation animationWithKeyPath:kGMSLayerCameraLongitudeKey];
68-
animation.duration = 2.0f;
69-
animation.timingFunction = curve;
70-
animation.toValue = @(location.coordinate.longitude);
71-
[_mapView.layer addAnimation:animation forKey:kGMSLayerCameraLongitudeKey];
72-
73-
animation = [CABasicAnimation animationWithKeyPath:kGMSLayerCameraBearingKey];
74-
animation.duration = 2.0f;
75-
animation.timingFunction = curve;
76-
animation.toValue = @0.0;
77-
[_mapView.layer addAnimation:animation forKey:kGMSLayerCameraBearingKey];
70+
[_mapView animateToCameraPosition:camera];
71+
[CATransaction commit];
72+
}
7873

79-
// Fly out to the minimum zoom and then zoom back to the current zoom!
80-
CGFloat zoom = _mapView.camera.zoom;
81-
NSArray *keyValues = @[ @(zoom), @(kGMSMinZoomLevel), @(zoom) ];
82-
CAKeyframeAnimation *keyFrameAnimation =
83-
[CAKeyframeAnimation animationWithKeyPath:kGMSLayerCameraZoomLevelKey];
84-
keyFrameAnimation.duration = 2.0f;
85-
keyFrameAnimation.values = keyValues;
86-
[_mapView.layer addAnimation:keyFrameAnimation forKey:kGMSLayerCameraZoomLevelKey];
74+
- (void)viewWillTransitionToSize:(CGSize)size
75+
withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
76+
_rotating = true;
77+
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
78+
[coordinator
79+
animateAlongsideTransition:nil
80+
completion:^(
81+
id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
82+
_rotating = false;
83+
}];
8784
}
8885

8986
@end

0 commit comments

Comments
 (0)