我的位置按钮没有出现在视图中(Google地图SDK,ios) [英] My location button not appearing in view (Google maps SDK, ios)

查看:120
本文介绍了我的位置按钮没有出现在视图中(Google地图SDK,ios)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的mapViewController.m文件:

  @interface MapViewController()

@property (强,非原子)GMSMapView * mapView;
@property(弱,非原子)IBOutlet GMSMapView * subView;

@end

@implementation MapViewController

- (void)viewDidLoad {
//创建一个GMSCameraPosition,告诉地图显示
//坐标-33.86,151.20在缩放级别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];
}

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

解决方案

解决方案。问题在于我将mapview添加为子视图,而不是添加到插座视图。现在它是固定的。

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.

解决方案

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

这篇关于我的位置按钮没有出现在视图中(Google地图SDK,ios)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆