MKMapview live vehicle tracking

My requirement is to create an application that displays live cockpit tracking. As well-known automotive applications such as Ola, uber, etc.

Please let me know how to update the annotation, even to turn the street and reverse the car. How to simulate a moving annotation using MKMapview. any library I should use. I searched but did not find any libraries

+4
source share
2 answers

I think the problem is the smooth rotation of the annotation on the map. How you can place your own image instead of the standard dot.

CMMotionManager, , , . , . useracceleration x, y z, tan. .

[motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMDeviceMotion *motion, NSError *error) {
    double angle = atan(motion.userAcceleration.x/motion.userAcceleration.y);
}];
+3

. , -? , . , MKAnnotation - : , . NewCoordinate ​​ . .

- :

@interface Vehicle : NSObject <MKAnnotation>

@property (nonatomic, readonly, copy) NSString *title;
@property (nonatomic, readonly, copy) NSString *subtitle;

@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, assign) CLLocationCoordinate2D newCoordinate;

@end

newCoordinate . , , .

// new coordinate obtained from networking
- (void)setNewCoordinate:(CLLocationCoordinate2D)newCoordinate {

    // implement the value moving part

    _newCoordinate = newCoordinate;
}

- , . , . hitTest , .

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
}

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
}

[UIView animateWithDuration:0 
                      delay:0 
                    options:UIViewAnimationOptionCurveEaseIn 
                 animations:^{

} completion:nil];

, , .

+2

Source: https://habr.com/ru/post/1659617/


All Articles