我在我的應用程序中顯示一個針的谷歌地圖視圖。谷歌地圖SDK不會打開針
func setUpGoogleMapView() {
let camera = GMSCameraPosition.camera(withLatitude: self.site.latitude, longitude: self.site.longitude, zoom: 15.0)
let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
mapView.frame = googleMapView.frame
self.view.addSubview(mapView)
let marker = GMSMarker()
marker.position = CLLocationCoordinate2D(latitude: self.site.latitude, longitude: self.site.longitude)
marker.title = self.site.name
marker.map = mapView
}
如果我手動調用UIApplication.shared.openURL
傳遞一個URL與查詢,它在不同的模式下打開(註釋不顯示地名,顯示緯度經度&代替)或打不開如果用戶沒有安裝谷歌地圖。
@IBAction func directionsButtonPressed(_ sender: UIButton) {
if (UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!)) {
UIApplication.shared.openURL(URL(string:
"comgooglemaps://?center=\(self.site.latitude),\(self.site.longitude)&zoom=14&views=traffic&q=\(self.site.latitude),\(self.site.longitude)")!)
} else {
print("Can't use comgooglemaps://");
}
}
如何使用UIApplication.shared.openURL
在safari中打開谷歌地圖?
如果我打電話給UIApplication.shared.openURL
,我應該如何使用谷歌地圖顯示地點名稱的別針?
我想使用UIApplication.shared.openURL
後有相同的方向模式。
你可以發佈你正在尋找所需的輸出的屏幕截圖? – Hooda
謝謝。它不會讓我添加圖像,因此我添加了一個鏈接 – NatukaKh
您顯示的屏幕截圖是您正在查找的輸出內容? – Hooda