gpt4 book ai didi

ios - Google map 无法缩放到我当前的位置

转载 作者:行者123 更新时间:2023-11-30 12:16:22 25 4
gpt4 key购买 nike

我必须在 Google map View 中绘制多个图钉,然后缩放到用户的当前位置。引脚已成功绘制,但未缩放到当前位置。任何帮助将不胜感激

 override func viewDidAppear(_ animated: Bool) {

if (self.googleMapsView == nil) {
self.googleMapsView = GMSMapView(frame: self.mapViewContainer.frame)
self.view.addSubview(self.googleMapsView)
print(AppDelegate.getAppDelegate().mapArray)
googleMapsView.clear()
for i in 0...AppDelegate.getAppDelegate().mapArray.count - 1 {
let lon = Double ((AppDelegate.getAppDelegate().mapArray[i]["lon"] as? String)!)
let lat = Double ((AppDelegate.getAppDelegate().mapArray[i]["lat"] as? String)!)
let tit = AppDelegate.getAppDelegate().mapArray[i]["location"] as? String
locateWithLongitude(lon: lon!,andLatitude: lat! ,andTitle: tit!)

}




let marker = GMSMarker(position: AppDelegate.getAppDelegate().myLocation)
let camera = GMSCameraPosition.camera(withLatitude: AppDelegate.getAppDelegate().myLocation.latitude, longitude: AppDelegate.getAppDelegate().myLocation.longitude, zoom: 11)
self.googleMapsView.camera = camera
marker.title = AppDelegate.getAppDelegate().sublocality
marker.map = self.googleMapsView
self.googleMapsView.animate(to: camera)

}
}




func locateWithLongitude(lon: Double, andLatitude lat: Double, andTitle title: String) {

DispatchQueue.main.async() { () -> Void in
let position = CLLocationCoordinate2DMake(lat, lon)
let marker = GMSMarker(position: position)
let camera = GMSCameraPosition.camera(withLatitude: lat, longitude: lon, zoom: 0)
self.googleMapsView.camera = camera
marker.title = title
marker.map = self.googleMapsView
}
}

最佳答案

您的缩放设置为 0,将其增加到 15/16,如下所示。

let camera  = GMSCameraPosition.camera(withLatitude: lat, longitude: lon, zoom: 16)

关于ios - Google map 无法缩放到我当前的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45396353/

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