My location button not appearing in view (Google maps SDK, ios)

Deadly 提交于 2019-12-14 03:53:46

问题


Here is my mapViewController.m file:

@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];
}

My problem is that the my location button doesn't appear, any help appreciated! :) Please tell me if you need to see more of my project.


回答1:


Got the correct answer. This will work even if you added the mapview as a subview. Tested and verified the same upto IOS 9.2

_mapView.settings.myLocationButton = YES



回答2:


Solved it. Problem was that I added the mapview as a subview, and not to the outlet view. Now its fixed.




回答3:


It happened to me once, and to make it easier, I used CoreLocation that's built into Cocoa Touch to get the current location and then used those coordinates to add a marker to the Google Map, I hope this would help.



来源:https://stackoverflow.com/questions/24703229/my-location-button-not-appearing-in-view-google-maps-sdk-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!