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

     

     

  • 相关阅读:
    2014 年最热门的国人开发开源软件TOP 100
    欢迎访问李培冠博客
    Go语言学习之路(持续更新)
    租房项目 获取地区信息服务
    租房项目 启动前的处理
    一步步带你用 FastDFS 搭建文件管理系统 详细的不得鸟
    golang 两个go程轮流打印一个切片
    golang 拷贝大切片一定比小切片代价大吗
    matlab 如何把数组A中与数组B中元素相同的元素删除
    golang 如何翻转含有中文 数字 英文字母等任意字符串
  • 原文地址:https://www.cnblogs.com/scaptain/p/4081689.html
Copyright © 2011-2022 走看看