GroundOverlayViewController.m 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #if !defined(__has_feature) || !__has_feature(objc_arc)
  2. #error "This file requires ARC support."
  3. #endif
  4. #import "SDKDemos/Samples/GroundOverlayViewController.h"
  5. #import <GoogleMaps/GoogleMaps.h>
  6. @implementation GroundOverlayViewController {
  7. GMSGroundOverlay *overlay_;
  8. }
  9. - (void)viewDidLoad {
  10. [super viewDidLoad];
  11. CLLocationCoordinate2D southWest = CLLocationCoordinate2DMake(40.712216, -74.22655);
  12. CLLocationCoordinate2D northEast = CLLocationCoordinate2DMake(40.773941, -74.12544);
  13. GMSCoordinateBounds *overlayBounds = [[GMSCoordinateBounds alloc] initWithCoordinate:southWest
  14. coordinate:northEast];
  15. // Choose the midpoint of the coordinate to focus the camera on.
  16. CLLocationCoordinate2D newark = GMSGeometryInterpolate(southWest, northEast, 0.5);
  17. GMSCameraPosition *camera = [GMSCameraPosition cameraWithTarget:newark
  18. zoom:12
  19. bearing:0
  20. viewingAngle:45];
  21. GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
  22. // Add the ground overlay, centered in Newark, NJ
  23. GMSGroundOverlay *groundOverlay = [[GMSGroundOverlay alloc] init];
  24. // Image from http://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg
  25. groundOverlay.icon = [UIImage imageNamed:@"newark_nj_1922.jpg"];
  26. groundOverlay.position = newark;
  27. groundOverlay.bounds = overlayBounds;
  28. groundOverlay.map = mapView;
  29. self.view = mapView;
  30. }
  31. @end