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

     

     

  • 相关阅读:
    javascript 构造函数,工厂模式,稳妥构造函数浅析
    javascript基本概念
    struts2 类型转换
    struts action
    struts2 配置(部分)
    struts2基本构成
    charapter 1
    java 内部类
    mysql zip 解压安装 (win10)
    python之random模块
  • 原文地址:https://www.cnblogs.com/scaptain/p/4081689.html
Copyright © 2011-2022 走看看