问题
I have 3 google maps instances. First loaded correctly, but second and third SOMETIMES loaded like on screenshot https://prnt.sc/uh3ecs or video: https://www.dropbox.com/s/oew3xsqy0z1r62f/recordit-bb8e22cb-c8a9-44bb-94d5-c6169b1d59f8.mp4?dl=0
My keys is correct. My bundle id in Google Cloud Console is correct, APIs enabled. I have free billing plan, may be this wrong?
AppDelegate code: In didFinishLaunchingWithOptions I call this function
func setupGoogleServices() {
GMSServices.provideAPIKey(googleAPIKey)
}
ViewController code:
private func setupMapView() {
mapView = GMSMapView.map(withFrame: view.frame, camera: GMSCameraPosition(latitude: 0, longitude: 0, zoom: 0))
view.insertSubview(mapView, at: .zero)
setupMapStyles()
mapView.delegate = self
}
Map styles is default google map silver theme:
private func setupMapStyles() {
if let filepath = Bundle.main.path(forResource: Constants.Resources.mapStyles, ofType: Constants.Resources.ResourceType.json) {
do {
let jsonString = try String(contentsOfFile: filepath)
mapView.mapStyle = try GMSMapStyle(jsonString: jsonString)
} catch {
LogManager.shared.printLog(title: "Error", content: error.localizedDescription)
}
}
}
Version: 3.10.0 iOS: 13.7 and 14.0 Xcode: 11 and 12 macOS: Catalina (10.15.6)
What I did wrong?
来源:https://stackoverflow.com/questions/64210738/more-than-one-google-maps-are-not-loaded-ios-swift