我收到这个错误:
This application has been blocked by the Google Maps API. This might be because of an incorrectly registered key.
当我尝试设置谷歌地图全景街景。如果我显示一个常规的地图视图,它会正常工作,看起来密钥注册正确。
我遵循了全景视图的指示,完全按照谷歌文档:
import UIKit
import GoogleMaps
class ViewController: UIViewController, GMSMapViewDelegate {
override func loadView() {
let panoView = GMSPanoramaView(frame: .zero)
self.view = panoView
panoView.moveNearCoordinate(CLLocationCoordinate2D(latitude: -33.732, longitude: 150.312))
}
}
有什么想法吗?
对我来说,解决方案是我需要将我在谷歌云平台中的项目链接到一个计费帐户。
一旦我做到了,街景就开始正常工作了。
标准的谷歌地图在没有账单账户的情况下运行良好,这让我最初感到困惑。
您需要为此对象配置委托。类似于:
import UIKit
import GoogleMaps
class ViewController: UIViewController, GMSMapViewDelegate {
override func loadView() {
let panoView = GMSPanoramaView(frame: .zero)
panoView.delegate = self
self.view = panoView
panoView.moveNearCoordinate(CLLocationCoordinate2D(latitude: -33.732, longitude: 150.312))
}
}
extension ViewController: GMSPanoramaViewDelegate {
func panoramaView(_ view: GMSPanoramaView, error: Error, onMoveNearCoordinate coordinate: CLLocationCoordinate2D) {
print("error: (error.localizedDescription)")
}
}