当前位置的蓝点不显示使用iOS的谷歌地图

时间:2014-10-19 00:10:24

标签: ios objective-c iphone google-maps xcode6

我试图在我的应用中实现当前位置。请参阅下面viewDidLoad的代码:

- (void)viewDidLoad {
    [super viewDidLoad];

    [self hideTabBar:self.tabBarController];

    // 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:CGRectZero camera:camera];
    mapView_.myLocationEnabled = YES;
    mapView_.settings.compassButton = YES;
    mapView_.settings.myLocationButton = YES;
    mapView_.accessibilityElementsHidden = NO;
    self.view = mapView_;

    // Creates a marker in the center of the map.
    GMSMarker *marker = [[GMSMarker alloc] init];
    marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
    marker.title = @"Sydney";
    marker.snippet = @"Australia";
    marker.map = mapView_;
}

我可以在iOS模拟器(iPhone 4s)中看到地图,标记设置为悉尼,但在任何地方都看不到蓝点。当前位置是否可行但UI元素是隐藏的?

感谢您的任何帮助/建议!

3 个答案:

答案 0 :(得分:1)

在我的应用中,我需要实现CLLocationManager并在自定义目标属性中设置NSLocationWhenInUseUsageDescription

希望这有帮助。

答案 1 :(得分:0)

模拟器 中,您需要设置如下自定义位置:

调试>地点>自定义位置... 然后输入您想要模拟的位置的纬度和经度。

注意:如果此方法不起作用,则只需选择高速公路云端硬盘,而不是自定义位置。单击高速公路驱动器后,请执行与上述相同的步骤。

答案 2 :(得分:0)

     func didTapMyLocationButton(for mapView: GMSMapView) -> Bool {


//if want to change the camera position

            if self.latDouble != 0.0 && self.longDouble != 0.0
            {
                let camera: GMSCameraPosition = GMSCameraPosition.camera(withLatitude: self.latDouble, longitude: self.longDouble, zoom: 18.0)
                self.mapView.camera = camera

            }

             self.mapView.isMyLocationEnabled = true
            self.mapView.reloadInputViews()
            return true
        }