我正在使用Gooogle Url计划快速按一下按钮来显示路线。打开本机google maps应用程序后,如何使用url回调方案返回我的应用程序。
我正在使用以下代码

if (UIApplication.sharedApplication().canOpenURL(NSURL(string:"comgooglemaps://")!)) {
            UIApplication.sharedApplication().openURL(NSURL(string:
                "comgooglemaps://?saddr=&daddr=\(place.latitude),\(place.longitude)&directionsmode=driving")!)

        } else {
            NSLog("Can't use comgooglemaps://");
        }
    }

我尝试引用此链接Google Map Url Scheme
如果有人知道怎么做,请用示例快速代码回答

最佳答案

您可以使用Google map 提供的OpenInGoogleMaps组件。它甚至可以让您对重定向到应用程序的URL进行编码,该URL显示在Google Maps应用程序的指示上方。

这是Swift中的代码:

var place: CLLocationCoordinate2D

var definition = GoogleDirectionsDefinition()
definition.destinationPoint = GoogleDirectionsWaypoint(location: place)
definition.travelMode = GoogleMapsTravelMode.Driving

OpenInGoogleMapsController.sharedInstance().openDirections(definition)

07-24 09:36
查看更多