GestureControlViewController.m 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #if !defined(__has_feature) || !__has_feature(objc_arc)
  2. #error "This file requires ARC support."
  3. #endif
  4. #import "SDKDemos/Samples/GestureControlViewController.h"
  5. #import <GoogleMaps/GoogleMaps.h>
  6. @implementation GestureControlViewController {
  7. GMSMapView *mapView_;
  8. UISwitch *zoomSwitch_;
  9. }
  10. - (void)viewDidLoad {
  11. [super viewDidLoad];
  12. GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-25.5605
  13. longitude:133.605097
  14. zoom:3];
  15. mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
  16. mapView_.autoresizingMask =
  17. UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  18. self.view = [[UIView alloc] initWithFrame:CGRectZero];
  19. [self.view addSubview:mapView_];
  20. UIView *holder = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 59)];
  21. holder.autoresizingMask =
  22. UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
  23. holder.backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.8f];
  24. [self.view addSubview:holder];
  25. // Zoom label.
  26. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(16, 16, 200, 29)];
  27. label.text = @"Zooming?";
  28. label.font = [UIFont boldSystemFontOfSize:18.0f];
  29. label.textAlignment = NSTextAlignmentLeft;
  30. label.backgroundColor = [UIColor clearColor];
  31. label.layer.shadowColor = [[UIColor whiteColor] CGColor];
  32. label.layer.shadowOffset = CGSizeMake(0.0f, 1.0f);
  33. label.layer.shadowOpacity = 1.0f;
  34. label.layer.shadowRadius = 0.0f;
  35. [holder addSubview:label];
  36. // Control zooming.
  37. zoomSwitch_ = [[UISwitch alloc] initWithFrame:CGRectMake(-90, 16, 0, 0)];
  38. zoomSwitch_.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  39. [zoomSwitch_ addTarget:self
  40. action:@selector(didChangeZoomSwitch)
  41. forControlEvents:UIControlEventValueChanged];
  42. zoomSwitch_.on = YES;
  43. [holder addSubview:zoomSwitch_];
  44. }
  45. - (void)didChangeZoomSwitch {
  46. mapView_.settings.zoomGestures = zoomSwitch_.isOn;
  47. }
  48. @end