Ios 使用firebase获取数据,但UI在模拟器上冻结

Ios 使用firebase获取数据,但UI在模拟器上冻结,ios,swift,firebase,firebase-realtime-database,Ios,Swift,Firebase,Firebase Realtime Database,我不熟悉使用firebase,我正在尝试从firebase获取数据 我从firebase获取驱动程序的纬度和经度,并将它们附加到纬度数组和经度数组中,然后在谷歌地图上创建多段线 当我在模拟器用户界面上运行代码时,放大和缩小需要时间,但在真正的设备iPhone4S上,地图并没有打开 我的数据库结构: func-API() { 让rootReference=FIRDatabase.database().reference() let DriverId=String(驱动程序id) 打印(“Driv

我不熟悉使用firebase,我正在尝试从firebase获取数据

我从firebase获取驱动程序的纬度和经度,并将它们附加到纬度数组和经度数组中,然后在谷歌地图上创建多段线
当我在模拟器用户界面上运行代码时,放大和缩小需要时间,但在真正的设备iPhone4S上,地图并没有打开

我的数据库结构:

func-API()
{
让rootReference=FIRDatabase.database().reference()
let DriverId=String(驱动程序id)
打印(“DriverId=\(DriverId)”)
让currentDatePath=rootReference.child(“gogoapp\u driver/\(DriverId)/\(dateFormatForDriverLocation!)”)
currentDatePath.observeEventType(.Value,withBlock:{中的快照
对于snapshot.children中的项{
让子项=项为!FIRDataSnapshot
让latitude=child.value![“latitude”]作为!字符串
设纬度值=双倍(纬度)
self.latitudarray.append(latitudeValue!)
让longitude=child.value![“longitude”]作为!字符串
让longitudeValue=双精度(经度)
self.longituderray.append(longitudeValue!)
}
self.createPolyline()
})
}
func createPolyline()
{
如果latitudeArray.count>0
{
让lastLat=latitudarray.last
让lastLong=longitudaray.last
让摄像机的坐标为:CLLocation=CLLocation(纬度:lastLat!,经度:lastLong!)
让camera=GMSCameraPosition.CameraWithLastlat!纬度,经度:lastLong!,缩放:12)
self.googleMapsView.camera=camera
let path=GMSMutablePath()
var line=GMSPolyline()
对于(变量i=0;i
 func API()
{
    let rootReference = FIRDatabase.database().reference()
    let DriverId = String(Driver_id)
    print("DriverId = \(DriverId)")
    let currentDatePath = rootReference.child("gogoapp_driver/\(DriverId)/\(dateFormatForDriverLocation!)")


    currentDatePath.observeEventType(.Value, withBlock: { snapshot in

        for item in snapshot.children {
            let child = item as! FIRDataSnapshot
            let latitude = child.value!["latitude"] as! String
            let latitudeValue = Double(latitude)
            self.latitudeArray.append(latitudeValue!)

            let longitude = child.value!["longitude"] as! String
            let longitudeValue = Double(longitude)
            self.longitudeArray.append(longitudeValue!)
        }

        self.createPolyline()

    })

}

 func createPolyline()
{
    if latitudeArray.count > 0
    {
        let lastLat = latitudeArray.last
        let lastLong = longitudeArray.last

        let coordinatesForCamera : CLLocation = CLLocation(latitude: lastLat!, longitude: lastLong!)
        let camera = GMSCameraPosition.cameraWithLatitude(lastLat!, longitude: lastLong!, zoom: 12)
        self.googleMapsView.camera = camera
        let path = GMSMutablePath()
        var line = GMSPolyline()
        for( var i = 0; i < latitudeArray.count; i++)
        {
            let currentLocation : CLLocation = CLLocation(latitude: latitudeArray[i], longitude: longitudeArray[i])

            let longitude :CLLocationDegrees = longitudeArray[i]
            let latitude :CLLocationDegrees = latitudeArray[i]
            let c1 = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)

            path.addCoordinate(c1)

            line = GMSPolyline(path: path)

            line.strokeWidth = 5.0
            line.map = googleMapsView

            marker.position = c1
            marker.map = googleMapsView
            marker.title = "\(ChildName)"

        }

        line = GMSPolyline(path: path)
        line.strokeWidth = 5.0
        line.map = googleMapsView

    }

}