zoukankan      html  css  js  c++  java
  • Google Map SDK for iOS

    根据 Google 提供的start for google map sdk for iOS进行一系列的设置,这里就不多说了

    https://developers.google.com/maps/documentation/ios/start

    google map sdk for iOS提供了全套的定位和显示服务,所以不需要调用CoreLocation中的CLLocationManager去管理Location

    只需要设置google map的

        mapView_.myLocationEnabled = YES;

        mapView_.settings.myLocationButton = YES;

    就可以实现位置的跟踪。

     

    但是在iOS8之后,同样的设置会无法定位,这是因为苹果在定位服务中强制开发者加入使用location信息的提醒,所以如果没有加入这个提醒,将无法获得定位坐标。

    如何去设置提醒呢?很简单:

    在XXXViewController.h文件中加入

    @property (nonatomic,retain) CLLocationManager *locationManager;

    在XXXViewController.m文件的viewDidload:中加入

    [_locationManager requestWhenInUseAuthorization];

    在XXXViewController.m中加入

    - (BOOL)ios8{
        return [[[UIDevice currentDevice] systemVersion]  isEqual: @"8.0"];
    }

    在Info.plist中加入

    NSLocationWhenInUseUsageDescription:This will be used to obtain or track your location.

    这样的键值对

    此时你就可以正常使用iPhone的定位功能了。

    Add a marker

    To add a marker you create a GMSMarker object that includes a positiontitle and set its map.

    The below example demonstrates how to add a marker to an existing GMSMapView object. The marker is created at coordinates10,10, and displays the string "Hello world" in an info window when clicked.

    CLLocationCoordinate2D position = CLLocationCoordinate2DMake(10, 10);
    GMSMarker *marker = [GMSMarker markerWithPosition:position];
    marker.title = @"Hello World";
    marker.map = mapView_;

    Remove a marker

    You can remove a marker from the map by setting your GMSMarker's map property to nil. Alternately, you can remove all of the overlays (including markers) currently on the map by calling the GMSMapView clear method.

    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.8683
                                                            longitude:151.2086
                                                                 zoom:6];
    mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
    ...
    [mapView_ clear];

     

     

  • 相关阅读:
    论文Objects as Points的解读
    图像增强
    from __future__ import absolute_import作用
    python降级
    conda命令总是出现Solving environment: failed错误
    ResNet网络结构
    卷积与池化操作后特征图大小的计算
    vs2015安装包下载与安装教程
    每隔几秒检测进程是否挂了
    阿里云部署flask
  • 原文地址:https://www.cnblogs.com/scaptain/p/4081689.html
Copyright © 2011-2022 走看看