Giter Site home page Giter Site logo

ios-trip's Introduction

iOS-trip

类似滴滴叫车的功能演示

前述

  • 高德官网申请Key.
  • 阅读开发指南.
  • 工程基于iOS 3D地图SDK实现
  • 运行demo请先执行pod install --repo-update 安装依赖库,完成后打开.xcworkspace 文件

核心类/接口

接口 说明 版本
DDDriverManager - (void)searchDriversWithinMapRect:(MAMapRect)mapRect; 模拟获取司机数据 n/a
DDDriverManager - (BOOL)callTaxiWithRequest:(DDTaxiCallRequest *)request; 模拟发起用车请求 n/a
DDSearchManager - (void)searchForRequest:(id)request completionBlock:(DDSearchCompletionBlock)block; 模拟搜索目的地 n/a
CustomMovingAnnotation - (void)addMoveAnimationWithKeyCoordinates:count:duration:name:completeCallback 继承自MAAnimatedAnnotation,为了实现汽车图标的平滑移动 4.5.0

核心难点

Objective-C

/**
*  司机相关管理类。获取司机数据、发送用车请求等。
*/
@interface DDDriverManager : NSObject

@property (nonatomic, weak) id<DDDriverManagerDelegate> delegate;

//根据mapRect取司机数据
- (void)searchDriversWithinMapRect:(MAMapRect)mapRect;

//发送用车请求:起点终点
- (BOOL)callTaxiWithRequest:(DDTaxiCallRequest *)request;

@end

///有位置更新时,更新汽车图标位置,使之平滑移动。
- (void)onUpdatingLocations:(NSArray *)locations forDriver:(DDDriver *)driver
{
    if ([locations count] > 0) {

        CLLocationCoordinate2D * locs = (CLLocationCoordinate2D *)malloc(sizeof(CLLocationCoordinate2D) * [locations count]);
        [locations enumerateObjectsUsingBlock:^(CLLocation * obj, NSUInteger idx, BOOL *stop) {
            locs[idx] = obj.coordinate;
        }];

        [_selectedDriver addMoveAnimationWithKeyCoordinates:locs count:[locations count] withDuration:5.0 withName:nil completeCallback:^(BOOL isFinished) {

        }];

        free(locs);
    }
}

Swift

/**
*  司机相关管理类。获取司机数据、发送用车请求等。
*/
class DDDriverManager {
	var delegate: DDDriverManagerDelegate?

	func searchDriversWithinMapRect(mapRect: MAMapRect) { ...... }

	func callTaxiWithRequest(request: DDTaxiCallRequest) -> Bool { ...... }
}

///有位置更新时,更新汽车图标位置,使之平滑移动。
func onUpdatingLocations(_ locations: Array<CLLocation>, forDriver deiver: DDDriver) {
    if locations.count > 0 {
        var locs = Array<CLLocationCoordinate2D>()
        for obj in locations {
            locs.append(obj.coordinate)
        }
        
        selectedDriver.addMoveAnimation(withKeyCoordinates: &locs, count: UInt(locations.count), withDuration: 5.0, withName: nil, completeCallback: nil)
    }
}

ios-trip's People

Contributors

cuishaobin avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.