ios - iOS 中的 GPS 导航

标签 ios swift gps

我正在开发一个 iPhone 应用程序。我已经使用 mapkit 来显示用户选择作为源和目的地的位置。用户还可以选择查看源和目的地之间的路线。我需要实现转弯导航。我正在使用谷歌地图。 是否有任何其他方式或任何第 3 方库,我可以通过它实现逐向导航?

最佳答案

提问前请先谷歌一下。有大量关于如何使用 mapkit 的优秀教程(免费和付费)。

这是其中之一:http://www.ioscreator.com/search?q=mapkit

对于轮流使用 map ,我在此处为 Apple map 设置了以下代码片段布局:

let address = "\(self.street!) \(self.zip!) \(self.city!) \(self.country!)"
let geoCoder = CLGeocoder()

geoCoder.geocodeAddressString(address, completionHandler:
    {(placemarks: [AnyObject]!, error : NSError!) in
        if error != nil {
            let errorAlert = UIAlertView(title: "Cannot locate address", message: "Geocode failed with error: \(error.localizedDescription)", delegate: self, cancelButtonTitle: "OK")
            errorAlert.show()
        }

        if placemarks.count > 0 {
            let placemark = placemarks[0] as! CLPlacemark
            let location = placemark.location

            println("\(location.coordinate.latitude) \(location.coordinate.longitude)")

            let coords = location.coordinate

            let place = MKPlacemark(coordinate: coords, addressDictionary: nil)
            let mapItem = MKMapItem (placemark: place)

            mapItem.name = locationName

            let options = [MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving, MKLaunchOptionsShowsTrafficKey: true]
            MKMapItem.openMapsWithItems([mapItem], launchOptions: options as [NSObject : AnyObject])

谷歌地图非常相似,而且很容易在网上找到一个写得很好的教程,这是我第一次使用:

swift navigate google maps

作为 google 中的搜索关键字

http://www.appcoda.com/google-maps-api-tutorial/

PS 我没有投反对票,但我理解那个人为什么这样做。

关于ios - iOS 中的 GPS 导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32881945/

相关文章:

Swift:如何显示明天的日期

android - 当我们从顶部状态栏启用位置时,如何关闭 LocationSettingsRequest 对话框?

android - 经纬度频繁变化如何解决

ios - 忽略 map 查看 :didSelectAnnotationView when long press is occuring

ios - Crashlytics - 检测到带有 API key xxx 的目标构建,但我们期待 yyy(组织...)

android - 固定移动应用程序的证书

java - 融合位置提供程序的最低 android 操作系统级别是多少

ios - 如何从 ios 中的静态库中获取 .m 文件

ios - Swift:平移(拖动)后如何使惯性平滑?

ios - 在特定的 CollectionViewCell 中隐藏 View