2017-01-06 19 views
1

私は道順がapですが、「directionsusinggoogle」のメンバーにあいまいです。それは、私のコードはここでは、方向などを計算するGoogleの場所apiを使用しています。そして、ここにエラーのイメージがあります。あなたがhttps://github.com/varshylmobile/MapManager/blob/master/MapManager.swiftを使用していて、スウィフト3にそれを変換していると仮定すると、道順アプリ曖昧なメンバー

enter image description here

@IBAction func ClickToGo(_ sender: AnyObject) { 
    if isValidPincode() { 
     mapManager.directionsUsingGoogle(from: txtFrom.text!, to: txtTo.text!) { (route,directionInformation, boundingRegion, error) ->() in 

      if(error != nil){ 
       print(error) 
      } 
      else{ 
       let pointOfOrigin = MKPointAnnotation() 
       pointOfOrigin.coordinate = route!.coordinate 
       pointOfOrigin.title = directionInformation?.object(forKey: "start_address") as! NSString as String 
       pointOfOrigin.subtitle = directionInformation?.object(forKey: "duration") as! NSString as String 

       let pointOfDestination = MKPointAnnotation() 
       pointOfDestination.coordinate = route!.coordinate 
       pointOfDestination.title = directionInformation?.object(forKey: "end_address") as! NSString as String 
       pointOfDestination.subtitle = directionInformation?.object(forKey: "distance") as! NSString as String 

       let start_location = directionInformation?.object(forKey: "start_location") as! NSDictionary 
       let originLat = start_location.object(forKey: "lat")?.doubleValue 
       let originLng = start_location.object(forKey: "lng")?.doubleValue 

       let end_location = directionInformation?.object(forKey: "end_location") as! NSDictionary 
       let destLat = end_location.object(forKey: "lat")?.doubleValue 
       let destLng = end_location.object(forKey: "lng")?.doubleValue 

       let coordOrigin = CLLocationCoordinate2D(latitude: originLat!, longitude: originLng!) 
       let coordDesitination = CLLocationCoordinate2D(latitude: destLat!, longitude: destLng!) 

       pointOfOrigin.coordinate = coordOrigin 
       pointOfDestination.coordinate = coordDesitination 
       if let web = self.drawMap { 
        DispatchQueue.main.async { 
        self.removeAllPlacemarkFromMap(shouldRemoveUserLocation: true) 
        web.add(route!) 
        web.addAnnotation(pointOfOrigin) 
        web.addAnnotation(pointOfDestination) 
        web.setVisibleMapRect(boundingRegion!, animated: true) 
        print(directionInformation) 
        self.tableData = directionInformation! 
        } 
       } 
      } 
     } } 
} 
+0

あなたは私たちですか? https://github.com/varshylmobile/MapManager/blob/master/MapManager.swift – SwiftArchitect

答えて

2

、APIは以下の署名がありますので、

func directionsUsingGoogle(from:NSString, to:NSString, 
    directionCompletionHandler:DirectionsCompletionHandler) 

func directionsUsingGoogle(from:CLLocationCoordinate2D, to:CLLocationCoordinate2D, 
    directionCompletionHandler:DirectionsCompletionHandler) 

func directionsUsingGoogle(from:CLLocationCoordinate2D, to:NSString, 
    directionCompletionHandler:DirectionsCompletionHandler) 

お知らせNSString、:

mapManager.directionsUsingGoogle(
    from: txtFrom.text! as NSString, 
    to: txtTo.text! as NSString, 
    directionCompletionHandler: {(
     _ route:MKPolyline?, 
     _ directionInformation:NSDictionary?, 
     _ boundingRegion:MKMapRect?, 
     _ error:String?) in 
     ... 
    } 
) 
+0

OTですが、コンパイラのメッセージが「あいまいなメンバ」なのはなぜですか? 、String ... 'が存在する – MathewS

+0

すばらしい建築家私はあなたが何か他のものを手助けできるかどうか疑問に思っていた – user7222919

+0

確かに - Stack Overflowであなたの質問を投稿し、ここへのリンクを置く – SwiftArchitect