如何通过程序快速打开具有多个目标坐标的地图应用程序?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何通过程序快速打开具有多个目标坐标的地图应用程序?相关的知识,希望对你有一定的参考价值。

我想使用Swift(4.2)打开Apple Map Application,但是我想传递多个目标坐标而不是仅传递一个,因此我可以开始导航多个目标。我正在共享一个目的地坐标的代码。适用于Google Map的解决方案我找不到适用于ios Native Maps的任何解决方案。

func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
    guard let locValue: CLLocationCoordinate2D = manager.location?.coordinate else { return }
    manager.stopUpdatingLocation()
    self.coordinations = CLLocationCoordinate2D(latitude: locValue.latitude,longitude: locValue.longitude)
    let source = MKMapItem(placemark: MKPlacemark(coordinate: CLLocationCoordinate2D(latitude: self.coordinations.latitude, longitude: self.coordinations.longitude)))
    source.name = "Your Location"

    if(self.customerData[self.selectedRow].latitude! != "" && self.customerData[self.selectedRow].longitude! != ""){
        var destination = MKMapItem(placemark: MKPlacemark(coordinate: CLLocationCoordinate2D(latitude: CLLocationDegrees(self.customerData[self.selectedRow].latitude!)!, longitude: CLLocationDegrees(self.customerData[self.selectedRow].longitude!)!)))
        destination.name = self.customerData[self.selectedRow].companyname!

        MKMapItem.openMaps(with: [source, destination], launchOptions: [MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving])
        print("Current Location = \(locValue.latitude) \(locValue.longitude)")
    }
    else{
        Global.sharedInstance.showStatusMessage(aMessage: txt_PleaseUpdateYourCustomersLatitudeLongitude, aStatus: K_Warning)
    }
}
答案

使用googleMaps

1.GoogleMaps的实现。

2。并实施Google Map委托。

使用以下链接:-

访问https://developers.google.com/maps/documentation/ios-sdk/map-with-marker

以上是关于如何通过程序快速打开具有多个目标坐标的地图应用程序?的主要内容,如果未能解决你的问题,请参考以下文章

在地图应用程序中快速获取路线

如何存储多个坐标和地图套件绘图路线

如何在 Phonegap 应用程序中获取点击地图的坐标?

如何在 iPhone 地图应用程序中打开 KML 文件?

带有多个目标的苹果或谷歌地图的 ios 导航

打开图形地图布局