ARCarMovement
这是 Google Map 上的导航示例。这里的标记随着车辆的移动而移动,转弯方式如 Uber 在其应用中所做。使用旧坐标和新坐标来 animate 航向值,标记在移动。
入门
要运行项目,克隆仓库,然后首先从 ARCarMovement 目录运行 pod install
安装
ARCarMovement 可通过 CocoaPods 获得。要安装它,只需将以下行添加到您的 Podfile 中
pod 'ARCarMovement'
先决条件
要使用 ARCarMovement 为 iOS 构建项目,您需要 Xcode 8.0 或更高版本。
用法
将您的 Google Maps API 密钥按以下方式添加到 AppDelegate.m 中
[GMSServices provideAPIKey:@"YOUR_API_KEY"];
对于 Objective-C 项目
- 将 ARCarMovement.swift 拖放到您的项目中。
- 将弹出一个窗口并询问“您想要配置Objective-C桥接头吗?”
- 选择“是”。
- 点击您的Xcode项目文件(可选)
- 点击“构建设置”
- 找到搜索栏并搜索定义模块。
- 将值更改为是。
- 在App委托或您想导入的位置,添加以下内容:#import "ARCarMovement-Swift.h" 注意: #import "< Defined Module Name >-Swift.h"
将以下导入语句添加到您的ViewController.h中,如下所示
#import "ARCarMovement-Swift.h" // NOTE: #import "<Your Defined Module Name>-Swift.h"
在ViewController.m中创建一个ARCarMovement属性
@property (strong, nonatomic) ARCarMovement *moveMent;
//alloc
//
self.moveMent = [[ARCarMovement alloc]init];
self.moveMent.delegate = self;
所需公共方法是
/**
* assign the specified details to be work with animation for the Marker.
*/
public func ARCarMovement(marker: GMSMarker, oldCoordinate: CLLocationCoordinate2D, newCoordinate:CLLocationCoordinate2D, mapView: GMSMapView, bearing: Float) {
//code here
}
所需代理方法是
/**
* Tells the delegate that the specified marker will be work with animation.
*/
- (void)ARCarMovementMoved:(GMSMarker * _Nonnull)Marker;
对于Swift项目,只需将ARCarMovement.swift拖放到您的项目中。
作者
Antony Raphel - 初版工作 - ARCarMovement
由Antony Raphel制作,@antonypr717于2017年6月5日。
联系
分享改进此项目的反馈和想法,我很乐意听听。您也可以在@antonypr717上关注我。
许可
ARCarMovement可在MIT许可下使用。有关更多信息,请参阅LICENSE文件。