我想在我的應用程序中使用谷歌地圖,但試圖運行模擬器時,它只適用於iPhone 6s加模擬器,但不在其他方面。我嘗試在我的實際手機iPhone 5上進行測試,但仍然無法正常工作。谷歌地圖項目不會運行在設備上或任何模擬器之前6s加 - Xcode 7
我確信google放置api,映射sdk,還有google放置api的web服務(不知道爲什麼,但是看起來我需要這個也啓用了,這些是否會互相干擾?)都已啓用。
@IBOutlet weak var mapViewContainer: UIView!
var googleMapView: GMSMapView!
let locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
self.locationManager.requestAlwaysAuthorization()
self.locationManager.requestWhenInUseAuthorization()
if CLLocationManager.locationServicesEnabled() {
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.startMonitoringSignificantLocationChanges()
}
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
self.googleMapView = GMSMapView(frame: self.mapViewContainer.frame)
self.googleMapView.animateToZoom(15.0)
self.view.addSubview(self.googleMapView)
self.googleMapView.layoutIfNeeded()
}
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let location:CLLocationCoordinate2D = manager.location!.coordinate
let marker = GMSMarker(position: location)
marker.title = "I'm here!"
marker.map = self.googleMapView
self.googleMapView.animateToLocation(location)
}
此外,我收到一個由「ClientParametersRequest」組成的錯誤,然後它從7倒計數;不過,這似乎並沒有影響我的代碼,因爲我從Google地圖和Google地方API中獲取所需的所有數據。我不知道它是否會影響地圖?
*尋求調試幫助的問題(「爲什麼不是這個代碼工作?」)必須包括所需的行爲,特定的問題或錯誤以及在問題本身中重現問題所需的最短代碼。沒有明確問題陳述的問題對其他讀者無益。請參閱:如何創建[mcve]。*請[編輯]您的問題以包含足夠的代碼以供其他人查看發生了什麼。 – BSMP
按要求做了編輯 – lifewithelliott
嘗試創建另一個Xcode項目,只是複製所有的代碼,做了一切,但現在6/6s模擬器是清澈透明的沒有問題在6/6s但仍然不能在5/5s模擬器? – lifewithelliott