问题描述
我正在使用google map sdk。我想每5秒更新一次pin的gps坐标。目前我只是更新GMSMarker的位置属性。但它会产生跳跃效应。我想在地图上平滑地移动标记。
这里是我的代码来更新标记的位置
- (void)updateLocationoordinates(CLLocationCoordinate2D)坐标
{
if(marker == nil){
marker = [GMSMarker markerWithPosition:coordinates];
marker.icon = [UIImage imageNamed:CAR_FOUND_IMAGE];
marker.map = mapView_;
} else
marker.position = coordinates;
更多类似这样的内容:
[CATransaction begin];
[CATransaction setAnimationDuration:2.0];
marker.position = coordindates;
[CATransaction commit];
我们使您可以使用,用于动画Google地图。
对于一个工作示例,请参阅SDK示例应用程序中的 AnimatedCurrentLocationViewController。{c,m}
p>
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 effect. I want to move marker smoothly on map.
Here is my code to update position of marker
-(void)updateLocationoordinates(CLLocationCoordinate2D) coordinates
{
if (marker == nil) {
marker = [GMSMarker markerWithPosition:coordinates];
marker.icon = [UIImage imageNamed:CAR_FOUND_IMAGE];
marker.map = mapView_;
} else
marker.position = coordinates;
}
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.
这篇关于如何平滑移动GMSMarker沿着目标c中的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!