Как анимировать полилинию одновременно с маркером в гугл картах в ios? - PullRequest
0 голосов
/ 11 апреля 2020

Я хочу перемещать полилинию с маркером, когда любое транспортное средство перемещается в моем приложении, для отслеживания маршрута, пройденного транспортным средством ... Я могу добиться анимации маркера или анимации полилинии отдельно, но не параллельно ... (Я хочу переместите маркер и черную цветную полилинию одновременно, как показано на рисунке) Ниже приведен код, который я использую

fun c animate (из источника: CLLocationCoordinate2D, по назначению: CLLocationCoordinate2D) {// Keep Rotation Short

    CATransaction.begin()
    CATransaction.setAnimationDuration(1)
    marker.rotation =  CLLocationDegrees(getHeadingForDirection(fromCoordinate: source, toCoordinate: destination))
    // marker.rotation = direction[index]
    marker.groundAnchor = CGPoint(x: CGFloat(0.5), y: CGFloat(0.5))
    CATransaction.commit()

    // Movement
    CATransaction.begin()
    CATransaction.setAnimationDuration(3)
    CATransaction.setCompletionBlock({
        // you can do something here
        self.marker.rotation = self.direction[self.index]
        //self.drawRoute(path: self.path, animated: true)
    })

    let t = GMSGeometryInterpolate(source, destination, 1.0)
    path.add(t)

    rectangle = GMSPolyline(path: path)
    rectangle.strokeWidth = 5.0
    let styles = [GMSStrokeStyle.solidColor(.clear),
                  GMSStrokeStyle.solidColor(.black)]
    let lengths: [NSNumber] = [10, 10]
    rectangle.spans = GMSStyleSpans(rectangle.path!, styles, lengths,GMSLengthKind.rhumb)

    marker.position = destination
    //  marker.map = showMap
    rectangle.map = showMap

    // Center Map View
    // let camera = GMSCameraPosition.camera(withTarget: destination, zoom: self.showMap.camera.zoom)
    // self.showMap.animate(to: camera)
    let camera = GMSCameraUpdate.setTarget(destination)
    showMap.animate(with: camera)
    CATransaction.commit()

}

enter image description here параллельно.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...