目前我正在制作像uber这样的应用程序,我想在用户地图上显示司机移动的位置。我已经有了基于这些坐标的司机坐标,如何在我的地图上移动标记。
例:目前我正在做两个应用,一个是用户端,另一个是驱动端。如果用户想要从一个位置旅行到另一个位置。此时,用户应请求特定的驱动程序。
如果驾驶员接受该请求,意味着在用户端我将获得驾驶员当前位置纬度和经度,但问题是我需要在GoogleMaps上显示该驾驶员汽车(自定义图像)图像与移动动画
如果有人知道的话。请帮我解决这个问题?
发布于 2016-05-19 16:09:29
marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(lat,
lng);
[marker setIcon:[UIImage imageNamed:kMarkerImage]];
marker.map = self.mapView_;如果要获得驱动程序坐标,您必须不断地发出HTTP请求(1-2 sec delay in each call)。
如果您使用的是用户坐标,那么您也必须执行相同的步骤。
然后你必须首先Clear地图,否则你会得到multiple标记添加到它上。然后使用NewCordinates添加新的标记。
[self.mapView_ clear];发布于 2016-07-21 00:23:53
接受两个CLLocationCoordinate2D类型的变量:
Last_Location = last locaiton of your marker
Current_Location = current location of marker在获得第一次位置更新后,最初的Last_Location和Current_Location将是相同的,编写以下代码:
let p1: MKMapPoint = MKMapPointForCoordinate(Last_Location)
let p2: MKMapPoint = MKMapPointForCoordinate(Current_Location)
let dist: CLLocationDistance = MKMetersBetweenMapPoints(p1, p2)
CATransaction.begin()
CATransaction.setAnimationDuration(6.0)
your_marker.position = Last_Location
your_marker.position = Current_Location
CATransaction.commit()
Last_Location = Current_Location在获得新的位置更新后调用上面的代码行。希望这能有所帮助:-)
https://stackoverflow.com/questions/37316767
复制相似问题