How to smoothly move GMSMarker along coordinates in Objective c

后端 未结 3 1771
盖世英雄少女心
盖世英雄少女心 2020-12-01 10:03

I\'m using google map sdk. I want to update gps coordinates of pin after each 5 seconds. Currently I\'m just updating position attribute of GMSMarker. But it gives jump effe

相关标签:
3条回答
  • 2020-12-01 10:22

    Change your else block to be something more like this:

    [CATransaction begin];
    [CATransaction setAnimationDuration:2.0];
    marker.position = coordindates;
    [CATransaction commit];
    

    We enable you to use Core Animation for animating Google Maps.

    For a worked sample, please see AnimatedCurrentLocationViewController.{c,m} in the SDK sample application.

    0 讨论(0)
  • 2020-12-01 10:23

    Brett's Answer in swift -3 and 4

    CATransaction.begin()
    CATransaction.setAnimationDuration(2.0)
    marker.position = coordindates
    CATransaction.commit()
    
    0 讨论(0)
  • 2020-12-01 10:37

    just Initialize marker in view did load and update it when you want to do it no need of any kind of animation like

    - (void)viewDidLoad {
        [super viewDidLoad];
        ..write code here
            marker = [[GMSMarker alloc] init];
    }
        marker.position = CLLocationCoordinate2DMake([latitudue doubleValue], [longitude doubleValue]);
    
    0 讨论(0)
提交回复
热议问题