我已經添加了一個路線,並且我還添加了點標記的方式。我想沿着路線順利地將標記從一個GPS座標點移動到另一個座標點。誰能幫我這個?這裏是用來添加標記的代碼。Swift:如何平穩移動GMSMarker在2個座標之間
func configureMapAndMarkersForRoute() {
viewGMap.camera = GMSCameraPosition.cameraWithTarget(mapTasks.originCoordinate, zoom: 9.0)
originMarker = GMSMarker(position: self.mapTasks.originCoordinate)
originMarker.map = self.viewGMap
originMarker.icon = GMSMarker.markerImageWithColor(UIColor.greenColor())
originMarker.title = self.mapTasks.originAddress
destinationMarker = GMSMarker(position: self.mapTasks.destinationCoordinate)
destinationMarker.map = self.viewGMap
destinationMarker.icon = GMSMarker.markerImageWithColor(UIColor.redColor())
destinationMarker.title = self.mapTasks.destinationAddress
if waypointsArray.count > 0 {
var i = 0
for waypoint in waypointsArray {
let lat: Double = (waypoint.componentsSeparatedByString(",")[0] as NSString).doubleValue
let lng: Double = (waypoint.componentsSeparatedByString(",")[1] as NSString).doubleValue
let marker = GMSMarker(position: CLLocationCoordinate2DMake(lat, lng))
marker.map = viewGMap
marker.icon = GMSMarker.markerImageWithColor(UIColor.purpleColor())
marker.title = locationNameArray[i]
markersArray.append(marker)
i += 1
}
}
}
爲什麼每次都添加標記?只是沿着路徑移動單個標記... –
@ kishan94是的。這就是我想要做的。你能幫助我嗎? –
如果您發現我的解決方案正確,請將答案標記爲正確。 –