-1

我想在我的應用程序中使用谷歌地圖,但試圖運行模擬器時,它只適用於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中獲取所需的所有數據。我不知道它是否會影響地圖?

5s

enter image description here

+0

*尋求調試幫助的問題(「爲什麼不是這個代碼工作?」)必須包括所需的行爲,特定的問題或錯誤以及在問題本身中重現問題所需的最短代碼。沒有明確問題陳述的問題對其他讀者無益。請參閱:如何創建[mcve]。*請[編輯]您的問題以包含足夠的代碼以供其他人查看發生了什麼。 – BSMP

+0

按要求做了編輯 – lifewithelliott

+0

嘗試創建另一個Xcode項目,只是複製所有的代碼,做了一切,但現在6/6s模擬器是清澈透明的沒有問題在6/6s但仍然不能在5/5s模擬器? – lifewithelliott

回答

0

在學習如何操作和執行谷歌地圖到我的iOS項目,到處都是我在網上搜索我讀,我應該使用的API密鑰的類型是服務器密鑰,iOS鍵似乎不起作用,導致許多錯誤。

我的應用程序在Xcode中工作得很好,能夠在幾天前運行該程序,這似乎很奇怪。剛剛嘗試嘗試iOS密鑰,現在可以在Xcode中完美工作。

所以答案是使用iOS密鑰,它將允許地圖出現在所有設備上。

相關問題