【问题标题】:I want to open Google maps app with turn by turn directions with voice navigation in iOS我想在 iOS 中通过语音导航打开 Google 地图应用程序
【发布时间】:2014-03-21 18:38:33
【问题描述】:

我想通过语音导航打开默认的谷歌地图应用。 我已使用以下代码打开带有源位置和目标位置的谷歌地图应用程序。谷歌地图应用程序打开正常,转弯方向也可以使用,但语音导航不起作用。 请帮我解决这个问题。

NSString* url = [NSString stringWithFormat: @"googlemaps://maps.google.com/maps?output=embed&saddr=%f,%f&daddr=%f,%f",[@"30.886537" doubleValue], [@"75.838870" doubleValue],[@"30.711423" doubleValue],[@"76.690839" doubleValue]];
    [[UIApplication sharedApplication] openURL: [NSURL URLWithString:url]];

【问题讨论】:

    标签: ios google-maps maps


    【解决方案1】:

    请尝试以下功能:

    location = "(self.street!) (self.zip!) (self.city!) (self.country!)"
    func showLocationPoints(location:String)
    {
    
        let geocoder:CLGeocoder = CLGeocoder()
        geocoder.geocodeAddressString(location, completionHandler: {(placemarks, error) -> Void in
    
            if((error) != nil){
                print("Error", error)
            }
            else if let placemark = placemarks!.first
            {
                let coordinates:CLLocationCoordinate2D = placemark.location!.coordinate
                let pointAnnotation:MKPointAnnotation = MKPointAnnotation()
                pointAnnotation.coordinate = coordinates
                pointAnnotation.title = "Apple HQ"
    
                let span:MKCoordinateSpan = MKCoordinateSpanMake(0.01 , 0.01)
                let region:MKCoordinateRegion = MKCoordinateRegionMake(coordinates, span)
                self.mapView?.setRegion(region, animated: true)
    
                self.mapView?.addAnnotation(pointAnnotation)
                self.mapView?.centerCoordinate = coordinates
                self.mapView?.selectAnnotation(pointAnnotation, animated: true)
                print("Added annotation to map view")
    
                let place = MKPlacemark(coordinate: coordinates, addressDictionary: nil)
                let mapItem = MKMapItem (placemark: place)
    
                mapItem.name = location
    
                let options = [MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving, MKLaunchOptionsShowsTrafficKey: true]
                MKMapItem.openMapsWithItems([mapItem], launchOptions: options as? [String : AnyObject])
    
            }
        })
    }
    

    【讨论】:

    • 他问的是谷歌地图,而不是苹果地图。
    猜你喜欢
    • 2015-04-12
    • 1970-01-01
    • 2017-12-19
    • 1970-01-01
    • 1970-01-01
    • 2018-07-20
    • 2013-11-22
    • 2013-11-20
    • 1970-01-01
    相关资源
    最近更新 更多