GMSMapView animateToCameraPosition zoom in - zoom out animation

前端 未结 2 790
-上瘾入骨i
-上瘾入骨i 2021-01-12 08:08

I am using Google maps services in iOS (Swift) and Android. In android, the map view has a method called animatreCamera that has an animation in which the movem

2条回答
  •  再見小時候
    2021-01-12 08:40

    Swift 4:

       func delay(seconds: Double, closure: @escaping () -> ()) {
        DispatchQueue.main.asyncAfter(deadline: .now() + seconds) {
            closure()
        }
      }
    

    Then call it :

        delay(seconds: 0.5) { () -> () in
                let zoomOut = GMSCameraUpdate.zoom(to: 10)
                self.mapView.animate(with: zoomOut)
    
                self.delay(seconds: 0.5, closure: { () -> () in
    
                var vancouver = CLLocationCoordinate2DMake(49.26,-123.11)
                var vancouverCam = GMSCameraUpdate.setTarget(vancouver)
                self.mapView.animate(toLocation: vancouverCam)
    
                self.delay(seconds: 0.5, closure: { () -> () in
                     let zoomIn = GMSCameraUpdate.zoom(to: 15)
                     self.mapView.animate(with: zoomIn)
    
                    })
                })
            }
    

提交回复
热议问题