GestureControlViewController.m 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright 2016 Google Inc. All rights reserved.
  3. *
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
  6. * file except in compliance with the License. You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software distributed under
  11. * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
  12. * ANY KIND, either express or implied. See the License for the specific language governing
  13. * permissions and limitations under the License.
  14. */
  15. #import "GoogleMapsDemos/Samples/GestureControlViewController.h"
  16. #import <GoogleMaps/GoogleMaps.h>
  17. @implementation GestureControlViewController {
  18. GMSMapView *_mapView;
  19. UISwitch *_zoomSwitch;
  20. }
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-25.5605
  24. longitude:133.605097
  25. zoom:3];
  26. _mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
  27. _mapView.autoresizingMask =
  28. UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  29. self.view = [[UIView alloc] initWithFrame:CGRectZero];
  30. [self.view addSubview:_mapView];
  31. UIView *holder = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 59)];
  32. holder.autoresizingMask =
  33. UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
  34. holder.backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.8f];
  35. [self.view addSubview:holder];
  36. // Zoom label.
  37. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(16, 16, 200, 29)];
  38. label.text = @"Zooming?";
  39. label.font = [UIFont boldSystemFontOfSize:18.0f];
  40. label.textAlignment = NSTextAlignmentLeft;
  41. label.backgroundColor = [UIColor clearColor];
  42. label.layer.shadowColor = [[UIColor whiteColor] CGColor];
  43. label.layer.shadowOffset = CGSizeMake(0.0f, 1.0f);
  44. label.layer.shadowOpacity = 1.0f;
  45. label.layer.shadowRadius = 0.0f;
  46. [holder addSubview:label];
  47. // Control zooming.
  48. _zoomSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(-90, 16, 0, 0)];
  49. _zoomSwitch.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  50. [_zoomSwitch addTarget:self
  51. action:@selector(didChangeZoomSwitch)
  52. forControlEvents:UIControlEventValueChanged];
  53. _zoomSwitch.on = YES;
  54. [holder addSubview:_zoomSwitch];
  55. }
  56. - (void)didChangeZoomSwitch {
  57. _mapView.settings.zoomGestures = _zoomSwitch.isOn;
  58. }
  59. @end