코펜하겐 자전거 타는 사람을위한 앱을 만들었지 만 문제가 있습니다. Google지도를 휴대 전화에서 사용할 수없는 경우 앱에서 Apple지도를 열어야합니다.Swift : Google지도가 설치되지 않은 상태에서 앱을 열어야합니다.
코드는 정보 창을 탭하면 Google지도에 대한 탐색 (작동) 표시 할 필요가이
// OUTLETS!
@IBOutlet weak var googleMapsView: GMSMapView!
// VARIABLES!
var locationManager = CLLocationManager()
var M1: GMSMarker!
var M2: GMSMarker!
//Marker funtioncs
var markerFunctions: [GMSMarker: (() -> Void)]!
override func viewDidLoad() {
super.viewDidLoad()
// GET LOCATION WHILE USING APP
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
locationManager.startMonitoringSignificantLocationChanges()
initGoogleMaps()
}
// START GOOGLE MAPS!
func initGoogleMaps() {
// MARKERS
M1 = GMSMarker()
M1.position = CLLocationCoordinate2D(latitude: 55.65208178045790, longitude: 12.527047696518300)
M1.title = "Sjælør St."
M1.snippet = "Press for navigation"
M1.map = self.googleMapsView
M2 = GMSMarker()
M2.position = CLLocationCoordinate2D(latitude: 55.67530850095370, longitude: 12.583165039072400)
M2.title = "Børsen (Slotsholmsgade)"
M2.snippet = "Press for navigation"
M2.map = self.googleMapsView
// Marker functions
markerFunctions = [
M1: { UIApplication.shared.open(NSURL(string: "comgooglemaps-x-callback://" +
"?daddr=55.65208178045790,12.527047696518300&directionsmode=bicycling&zoom=17")! as URL)},
M2: { UIApplication.shared.open(NSURL(string: "comgooglemaps-x-callback://" +
"?daddr=55.67530850095370,12.583165039072400&directionsmode=bicycling&zoom=17")! as URL)},
것 같습니다. 그러나 Google지도 앱을 사용할 수없는 경우 '마커 기능'을 다시 작성하여 대신 Apple지도를 열 수 있습니까?
https://developer.apple.com/library/prerelease/content/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html? 어떤 것이 사용 가능한지 "canOpenURL()"을 확인하십시오. – Larme