2017-01-06 2 views
1

У меня есть указатели ap, но я получаю двусмысленный член ошибки «directionusinggoogle». Он использует google-сайты api для расчета направлений и т. Д. Вот мой код. И вот изображение ошибки.Направления приложения неоднозначный член

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

Предполагая, что вы используете https://github.com/varshylmobile/MapManager/blob/master/MapManager.swift и превратили его в Swift 3, то 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 , String ... 'существует – MathewS

+0

быстрый архитектор, мне было интересно, можете ли вы мне помочь с чем-то другим – user7222919

+0

Конечно - Отправьте свой вопрос о переполнении стека и поместите ссылку на него здесь – SwiftArchitect

Смежные вопросы