Skip to content

Instantly share code, notes, and snippets.

@ziyang0621
Created June 24, 2015 18:38
Show Gist options
  • Save ziyang0621/a049edb494e0322acf69 to your computer and use it in GitHub Desktop.
Save ziyang0621/a049edb494e0322acf69 to your computer and use it in GitHub Desktop.
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController {
GMSMapView *mapView_;
CLLocationManager *locationManager_;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
mapView_.settings.myLocationButton = YES;
self.view = mapView_;
// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
marker.title = @"Sydney";
marker.snippet = @"Australia";
marker.map = mapView_;
locationManager_ = [[CLLocationManager alloc] init];
locationManager_.delegate = self;
locationManager_.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager_ requestAlwaysAuthorization];
[locationManager_ startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray *)locations{
NSLog(@"location updated");
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment