ios - 谷歌地图不显示/加载ios
问题描述
我开始使用谷歌地图,首先它显示地图,但在它什么也没显示并且我的日志显示这个之后
CoreData:注释:无法在路径'/var/containers/Bundle/Application/EA2D4483-D98A-4D23-AFE4-ACDD86C0DF2A/Key Sensor.app/GoogleMaps.bundle/GMSCacheStorage.momd/StorageWithTileProto.omo 加载优化模型核心数据:注释:无法在路径“/var/containers/Bundle/Application/EA2D4483-D98A-4D23-AFE4-ACDD86C0DF2A/Key Sensor.app/GoogleMaps.bundle/GMSCacheStorage.momd/StorageWithTileProto.omo”加载优化模型CoreData:注释:失败在路径“/var/containers/Bundle/Application/EA2D4483-D98A-4D23-AFE4-ACDD86C0DF2A/Key Sensor.app/GoogleMaps.bundle/GMSCacheStorage.momd/StorageWithTileProto.omo”加载优化模型
我尝试过的事情
我在 api 控制台中限制了 bundle id。我还尝试删除 StorageWithTileProto.omo 文件。我清理了几次项目。我重启了几次手机。我还创建了新项目,显示相同的错误。
这是我的代码
import Foundation
import UIKit
import GoogleMaps
class GoogleMaps :UIViewController {
var gsmMapView: GMSMapView!
@IBOutlet weak var mapView: UIView!
let loacationManager = CLLocationManager()
override func viewDidLoad() {
navigationController?.navigationBar.barTintColor =
UIColor.hexStringToUIColor(hex: "#555555")
loacationManager.delegate = self
loacationManager.requestAlwaysAuthorization()
// Zoom to location
let camera = GMSCameraPosition.camera(withLatitude: 0,
longitude: 0, zoom: 6.0)
// get google Maps
gsmMapView = GMSMapView.map(withFrame: CGRect.zero, camera:
camera)
mapView.addSubview(gsmMapView)
}
func toast(message msg: String)
{self.navigationController?.view.makeToast(message: msg)}
}
extension GoogleMaps : CLLocationManagerDelegate{
func locationManager(_ manager: CLLocationManager,
didChangeAuthorization status: CLAuthorizationStatus) {
print("status \(status.rawValue)")
if(status != CLAuthorizationStatus.authorizedAlways){
permissionDialog()
return
}
loacationManager.startUpdatingLocation()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations
locations: [CLLocation]) {
toast(message: "didUpdateLocations")
guard let location = locations.first else {
return
}
// 7
// gsmMapView.camera = GMSCameraPosition(target:
location.coordinate,
// zoom: 15, bearing: 0, viewingAngle: 0)
//
// 8
loacationManager.stopUpdatingLocation()
}
func locationManager(_ manager: CLLocationManager,
monitoringDidFailFor region: CLRegion?, withError error: Error) {
print("Monitoring failed for region with identifier: \ .
(region!.identifier)")
}
func locationManager(_ manager: CLLocationManager, didFailWithError
error: Error) {
print("Location Manager failed with the following error: \ .
(error)")
}
func permissionDialog() {
self.toast(message: "Give Always Authorization Premission")
let alertController = UIAlertController(title: "Permission",
message: "Please go to
Settings and turn on the location alway permissions
for to work",
preferredStyle: .alert)
let settingsAction = UIAlertAction (title: "Settings", style:
.default, handler: ({ (_) -> Void in
guard let settingsUrl = URL(string:
UIApplication.openSettingsURLString) else {
return}
if(UIApplication.shared.canOpenURL(settingsUrl)){
UIApplication.shared.open(settingsUrl, options: [:], completionHandler: { (success) in })
}
}))
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel,
handler: nil)
alertController.addAction(settingsAction)
alertController.addAction(cancelAction)
self.present(alertController, animated: true, completion: nil)
}
}
我的 swift 版本是 4.2 ,构建目标版本是 12.1 。请让我知道我是什么
解决方案
尝试
gsmMapView = GMSMapView.map(withFrame: mapView.bounds, camera: camera)
mapView.addSubview(gsmMapView)
推荐阅读
- javascript - 如何修复错误:相邻的 JSX 元素必须包含在封闭标记中?在本机反应
- r - 当自变量满足条件时,循环遍历 GLM 模型中的因变量
- reactjs - npm 总是返回此错误“在 '...0.4.2 附近解析时 JSON 输入意外结束”:{“name”:“comma””
- c++ - 如何返回函数的参数个数?
- vue.js - “无法读取null的属性'0'”。是否可以在发生错误的视图中找出属性名称?
- html - 我正在尝试使用 res.sendFile 在 express 中显示一个 html 文件
- r - 使用 purrr 和 modify_if 替换嵌套的 ifelse
- macos - 如何解决arduino ide的“没有这样的xattr:com.apple.quarantine”错误和路径错误?
- reactjs - 如何从天气 API 数组(对于 React Redux)中获取单独的每日数组,该数组每 3 小时提供 5 天报告
- stata - 分组结果的汉明距离