В настоящее время я работаю с API Карт Google в своем проекте. Я пытаюсь установить камеру/увеличение по умолчанию для местоположения пользователя. Я сделаю это:
@implementation ViewController{
GMSMapView *mapView_;
}
@synthesize currentLatitude,currentLongitude;
- (void)viewDidLoad
{
[super viewDidLoad];
mapView_.settings.myLocationButton = YES;
mapView_.myLocationEnabled = YES;
}
- (void)loadView{
CLLocation *myLocation = mapView_.myLocation;
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(myLocation.coordinate.latitude, myLocation.coordinate.longitude);
marker.title = @"Current Location";
marker.map = mapView_;
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:myLocation.coordinate.latitude
longitude:myLocation.coordinate.longitude
zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
self.view = mapView_;
NSLog(@"%f, %f", myLocation.coordinate.latitude, myLocation.coordinate.longitude);
}
Однако это не работает, так как, когда я делаю
NSLog(@"%f, %f", myLocation.coordinate.latitude, myLocation.coordinate.longitude);
он возвращает 0, 0 и не дает координаты текущего местоположения. Как я могу правильно получить координаты пользователя?