ios - 如何在不旋转 map 的情况下将 GoogleMaps 居中?

标签 ios swift google-maps

我正在使用 Xcode 和 Swift 4。

在示例中,我将 map 上下颠倒(朝北朝下),然后按按钮将 map 居中到特定位置。但是当我这样做时, map 会自动转回(北面朝上)。

有没有办法在不旋转 map 的情况下将 GoogleMaps 居中到某个位置?

import UIKit
import GoogleMaps

class ViewController: UIViewController {
    @IBOutlet weak var mapView: GMSMapView!

    override func viewDidLoad() {
        super.viewDidLoad()
        mapView.animate(toBearing: 180)
    }

    @IBAction func button(_ sender: Any) {
        let camera = GMSCameraPosition.camera(withLatitude: 1.1111, longitude: 1.1111, zoom: 1)
        mapView.camera = camera
    }
}

最佳答案

遵循Apple的文档

rotateEnabled bool 值,表示是否使用 map 相机的航向信息。

@property(nonatomic, getter=isRotateEnabled) BOOLrotateEnabled 讨论 当此属性设置为 YES 并且有效的摄像机与 map 关联时,摄像机的航向角用于围绕其中心点旋转 map 平面。当此属性设置为“否”时,相机的航向角度将被忽略,并且 map 始终定向,以便正北位于 map View 的顶部。

当您按下按钮将其颠倒然后更改时 isRotateEnabled 为 no,然后将 map 居中,这可能会有所帮助

关于ios - 如何在不旋转 map 的情况下将 GoogleMaps 居中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54272118/

相关文章:

iphone - iPhone5 发布后为通用应用程序创建 Xib 文件时应遵循的常见做法

ios - 全屏 PushViewController

javascript - 从数据库生成 Google map 标记

ios - 如何在推送通知时导航到 View Controller

swift - 如何在@propertyWrapper 中获得 parent 的 self ?

ios - 获取、解析 JSON 对象,然后保存到 Core Data 会产生重复的记录

ios - 为什么没有调用 didReceiveRemoteNotification 但 didReceiveRemoteNotification :fetchCompletionHandler called when my app is in the foreground?

algorithm - 使用 Google Maps API 查找区域内的街道交叉路口

java - 如何实现实时跟踪?

ios - 使用 RKEntityMapping 和 RKRelationshipMapping 获取多条记录