我试图在我的应用程序的 View 中设置 map ,但我遇到了这个问题:
CoreData:注释:无法在路径 '/var/containers/Bundle/Application/35C61A40-48B9-40E0-A6F9-AB7492A15009/simply-convertor.app/GoogleMaps.bundle/GMSCacheStorage.momd/Storage 加载优化模型。奥莫 CoreData:注释:无法在路径“/var/containers/Bundle/Application/35C61A40-48B9-40E0-A6F9-AB7492A15009/simply-convertor.app/GoogleMaps.bundle/GMSCacheStorage.momd/Storage.omo”加载优化模型 CoreData:注释:无法在路径“/var/containers/Bundle/Application/35C61A40-48B9-40E0-A6F9-AB7492A15009/simply-convertor.app/GoogleMaps.bundle/GMSCacheStorage.momd/Storage.omo”加载优化模型
我向我的 ViewContoroller 添加了一个空 View ,并将其类型更改为 GMSMapView。 在 viewDidLoad 方法中,我从位置创建了一个新 map 并初始化了我的主 mapView:
override func viewDidLoad() {
super.viewDidLoad()
placesClient = GMSPlacesClient.shared()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.startMonitoringSignificantLocationChanges()
locationAuthStatus()
print(location.coordinate.latitude, location.coordinate.longitude)
let camera = GMSCameraPosition.camera(withLatitude: 31.9650070083707, longitude: 34.7899029677496, zoom: 6.0)
let map = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
self.mapView = map
// Creates a marker in the center of the map.
let marker = GMSMarker()
marker.position = CLLocationCoordinate2D(latitude: 31.9650070083707, longitude: 34.7899029677496)
marker.title = "Home"
marker.snippet = "Home"
marker.map = mapView
}
问题是什么?
最佳答案
我发现我的问题.. 看来我误解了 GMSMapView 的初始化并且没有正确初始化..
在其他帖子中,我提到的 CoreData 错误是 Google API 的问题,它不会影响应用程序。
关于swift - 使用 Xcode 9 在 iOS 11 上发布 Google map API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46634225/