我是iOS开发的新手,正在尝试使用Google Maps SDK创建一个简单的应用程序。我正在按照Google Maps入门指南中列出的步骤进行操作。
我看到了类似的问题:Google Maps iOS SDK集成不加载地图,其中问题在于bundle ID。我确保这对我不适用。
我已经花了3天时间从头开始尝试新应用程序。
我看到了类似的问题:Google Maps iOS SDK集成不加载地图,其中问题在于bundle ID。我确保这对我不适用。
我已经花了3天时间从头开始尝试新应用程序。
I created a new api key, added my bundle ID.
I added API key:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. GMSServices.provideAPIKey("MYKEY") return true }
Following is the ViewController.swift:
import UIKit import GoogleMaps class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. let camera = GMSCameraPosition.camera(withLatitude: -33.86, longitude: 151.20, zoom: 6.0) let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera) view = mapView let marker = GMSMarker() marker.position = CLLocationCoordinate2D(latitude: -33.86, longitude: 151.20) marker.title = "Sydney" marker.snippet = "Australia" marker.map = mapView } }