gpt4 book ai didi

swift - 我无法将当前位置添加到 Google map

转载 作者:行者123 更新时间:2023-11-30 13:22:01 26 4
gpt4 key购买 nike

import UIKit
import GoogleMaps
import CoreLocation

class ViewController: UIViewController {

let locationManager = CLLocationManager()
var mapView: GMSMapView?


override func viewDidLoad() {
super.viewDidLoad()

GMSServices.provideAPIKey("XYZ")

let camera = GMSCameraPosition.cameraWithLatitude(37.621262,longitude: -122.378945, zoom: 12)
mapView = GMSMapView.mapWithFrame(CGRectZero, camera: camera)
view = mapView

}
}

我应该在这段代码中添加什么?

最佳答案

这应该对你有帮助,请检查。

import UIKit
import GoogleMaps
import CoreLocation

class ViewController: UIViewController {

let locationManager = CLLocationManager()
var mapView: GMSMapView?


override func viewDidLoad()
{
super.viewDidLoad()
GMSServices.provideAPIKey("XYZ")
let camera = GMSCameraPosition.camera(withLatitude: 37.621262,longitude: -122.378945, zoom: 12)
mapView = GMSMapView.map(withFrame: CGRect.init(), camera: camera)
// Below line is to default show user current location(Bue dot with circular accuracy radius around it)
mapView!.isMyLocationEnabled = true
view = mapView
}
}

希望有帮助。

关于swift - 我无法将当前位置添加到 Google map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37675639/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com