Google Maps GMSPanoramaView api被阻止

我收到此错误:

This application has been blocked by the Google Maps API. This might be because of an incorrectly registered key.

当我尝试设置Google地图全景街景时。如果我显示常规地图视图,则它可以正常工作,因此好像密钥已正确注册。

我完全按照Google文档的指示进行了全景查看:

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))
  }
}

有什么想法吗?

mqm07072009 回答:Google Maps GMSPanoramaView api被阻止

对我来说,解决方案是我需要将Google Cloud Platform中的项目链接到计费帐户。

一旦我这样做,街景便开始正常运行。

标准的Google地图在没有计费帐户的情况下也能正常工作,这最初使我感到困惑。

,

您需要为此对象配置委托。像这样:

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)")
    }
}
本文链接:https://www.f2er.com/3148764.html

大家都在问