Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var gmsPath = GMSMutablePath()
- var path = GMSPath()
- var polyline = GMSPolyline()
- var animationPath = GMSMutablePath()
- var animationPolyline = GMSPolyline()
- func polyline(){
- self.createPolyline(arrStep: arrPath, complitionBlock: { (success) in
- if success{
- print("Success")
- self.timer = Timer.scheduledTimer(timeInterval: 0.3, target: self, selector: #selector(self.animatePath), userInfo: nil, repeats: true)
- }else{
- print("Did not success")
- }
- })
- }
- ////Create Polyline On MAP
- func createPolyline(arrStep:[String],complitionBlock : @escaping (Bool)->Void){
- for points in arrStep{
- self.gmsPath.appendPath(path: GMSMutablePath(fromEncodedPath: points))
- self.polyline.path = gmsPath
- self.polyline.strokeColor = UIColor.blue
- self.polyline.strokeWidth = 4.0
- self.polyline.map = self.gmsMapView
- }
- complitionBlock(true)
- }
- ////Animate Path In Polyline
- @objc func animatePath() {
- if (self.i < self.gmsPath.count()){
- self.animationPath.add(self.gmsPath.coordinate(at: UInt(self.i)))
- self.animationPolyline.path = self.animationPath
- self.animationPolyline.strokeColor = UIColor.purple
- self.animationPolyline.strokeWidth = 4
- self.animationPolyline.map = self.gmsMapView
- self.i += 1
- }else{
- self.i = 0
- self.animationPath = GMSMutablePath()
- self.animationPolyline.map = nil
- }
- }
Add Comment
Please, Sign In to add comment