PanoramaViewController.m 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #if !defined(__has_feature) || !__has_feature(objc_arc)
  2. #error "This file requires ARC support."
  3. #endif
  4. #import "SDKDemos/Samples/PanoramaViewController.h"
  5. #import <GoogleMaps/GoogleMaps.h>
  6. static CLLocationCoordinate2D kPanoramaNear = {40.761388, -73.978133};
  7. static CLLocationCoordinate2D kMarkerAt = {40.761455, -73.977814};
  8. @interface PanoramaViewController () <GMSPanoramaViewDelegate>
  9. @end
  10. @implementation PanoramaViewController {
  11. GMSPanoramaView *view_;
  12. BOOL configured_;
  13. }
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. view_ = [GMSPanoramaView panoramaWithFrame:CGRectZero
  17. nearCoordinate:kPanoramaNear];
  18. view_.backgroundColor = [UIColor grayColor];
  19. view_.delegate = self;
  20. self.view = view_;
  21. }
  22. #pragma mark - GMSPanoramaDelegate
  23. - (void)panoramaView:(GMSPanoramaView *)panoramaView
  24. didMoveCamera:(GMSPanoramaCamera *)camera {
  25. NSLog(@"Camera: (%f,%f,%f)",
  26. camera.orientation.heading, camera.orientation.pitch, camera.zoom);
  27. }
  28. - (void)panoramaView:(GMSPanoramaView *)view
  29. didMoveToPanorama:(GMSPanorama *)panorama {
  30. if (!configured_) {
  31. GMSMarker *marker = [GMSMarker markerWithPosition:kMarkerAt];
  32. marker.icon = [GMSMarker markerImageWithColor:[UIColor purpleColor]];
  33. marker.panoramaView = view_;
  34. CLLocationDegrees heading = GMSGeometryHeading(kPanoramaNear, kMarkerAt);
  35. view_.camera =
  36. [GMSPanoramaCamera cameraWithHeading:heading pitch:0 zoom:1];
  37. configured_ = YES;
  38. }
  39. }
  40. @end