我的位置按钮未出现在视图中(Google 地图 SDK、ios)

问题描述 投票:0回答:4

这是我的mapViewController.m 文件:

@interface MapViewController()

@property (strong, nonatomic) GMSMapView* mapView;
@property (weak, nonatomic) IBOutlet GMSMapView *subView;

@end

@implementation MapViewController

    - (void) viewDidLoad{
    // Create a GMSCameraPosition that tells the map to display the
    // coordinate -33.86,151.20 at zoom level 6.
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
                                                        longitude:151.20
                                                             zoom:6];

    _mapView = [GMSMapView mapWithFrame:self.view.bounds camera:camera];

    _mapView.myLocationEnabled = YES;

    _mapView.settings.compassButton = YES;
    _mapView.settings.myLocationButton = YES;

    [self.subView addSubview:_mapView];
}

我的问题是我的位置按钮没有出现,感谢任何帮助! :) 如果您需要查看更多我的项目,请告诉我。

ios objective-c google-maps ios7
4个回答
13
投票

得到正确答案。即使您将地图视图添加为子视图,这也将起作用。在 IOS 9.2 之前进行了相同的测试和验证

_mapView.settings.myLocationButton = YES

4
投票

解决了。问题是我将地图视图添加为子视图,而不是添加到出口视图中。现在已经修复了。


0
投票

我曾经遇到过这种情况,为了方便起见,我使用 Cocoa Touch 内置的 CoreLocation 来获取当前位置,然后使用这些坐标将标记添加到 Google 地图,我希望这会有所帮助。


0
投票

斯威夫特5+

mapView.settings.myLocationButton = true
© www.soinside.com 2019 - 2024. All rights reserved.