我不知道';使用GMSPlacePickerViewController IOS时看不到地图

我不知道';使用GMSPlacePickerViewController IOS时看不到地图,ios,objective-c,google-maps,gmsplacepicker,Ios,Objective C,Google Maps,Gmsplacepicker,我想用地点选择器显示地图。我创建了所需的API,并将它们添加到我的AppDelegate.m中。然后,我在我的视图控制器中实现了以下代码: - (void)location { GMSPlacePickerConfig *config = [[GMSPlacePickerConfig alloc] initWithViewport:nil]; GMSPlacePickerViewController *placePicker = [[GMSPlacePickerViewCont

我想用地点选择器显示地图。我创建了所需的API,并将它们添加到我的AppDelegate.m中。然后,我在我的视图控制器中实现了以下代码:

 - (void)location
{
    GMSPlacePickerConfig *config = [[GMSPlacePickerConfig alloc] initWithViewport:nil];
    GMSPlacePickerViewController *placePicker = [[GMSPlacePickerViewController alloc] initWithConfig:config];
    placePicker.delegate = self;
    [self presentViewController:placePicker animated:YES completion:nil];
}

- (void)placePicker:(GMSPlacePickerViewController *)viewController didPickPlace:(GMSPlace *)place {
    [viewController dismissViewControllerAnimated:YES completion:nil];

    NSLog(@"Place name %@", place.name);
    NSLog(@"Place address %@", place.formattedAddress);
    NSLog(@"Place attributions %@", place.attributions.string);
}

- (void)placePickerDidCancel:(GMSPlacePickerViewController *)viewController {
    [viewController dismissViewControllerAnimated:YES completion:nil];

    NSLog(@"No place selected");
}
我得到了GMSPlacePickerViewController,但是在我的pin下没有map。
有什么想法吗?

当您使用viewport初始化placePickerConfig:nil时,它默认为用户的当前位置。在执行所有这些操作之前,请确保您拥有用户的位置。在初始化GMSPlacePickerConfig时,通过提供恒定的贴图坐标来测试贴图,如下所示:

let center = CLLocationCoordinate2DMake(-33.86, 151.20)
let northEast = CLLocationCoordinate2DMake(center.latitude + 0.001, center.longitude + 0.001)
let southWest = CLLocationCoordinate2DMake(center.latitude - 0.001, center.longitude - 0.001)
let viewport = GMSCoordinateBounds(coordinate: northEast, coordinate: southWest)
然后使用视口初始化placePickerConfig。 我使用了swift,因为我不知道obj-c,但你可以很容易地转换它。如果这是问题所在,您需要首先获取用户的坐标