作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在这张图片中GMSMapView
有两个标记
- Green marker is pickup location and
- Red marker is drop location marker
我想根据拾取位置旋转mapView,拾取位置希望从mapView的左侧开始,放置位置希望放置在mapView的右侧
旋转:GMSMapView
使用委托(delegate)方法或任何自定义方法
最佳答案
你可以这样尝试
extension FloatingPoint {
var degreesToRadians: Self { return self * .pi / 180 }
var radiansToDegrees: Self { return self * 180 / .pi }
}
在 View Controller 中
func getHeadingForDirection(fromCoordinate fromLoc: CLLocationCoordinate2D, toCoordinate toLoc: CLLocationCoordinate2D) -> Float {
let fLat: Float = Float((self.mapView.camera.target.latitude).degreesToRadians)
let fLng: Float = Float((self.mapView.camera.target.longitude).degreesToRadians)
let tLat: Float = Float((fromLoc.latitude).degreesToRadians)
let tLng: Float = Float((fromLoc.longitude).degreesToRadians)
let degree: Float = (atan2(sin(tLng - fLng) * cos(tLat), cos(fLat) * sin(tLat) - sin(fLat) * cos(tLat) * cos(tLng - fLng))).radiansToDegrees
if degree >= 0 {
return degree
} else {
return 360 + degree
}
}
在mapView(_mapView:GMSMapView,idleAt位置:GMSCameraPosition)
self.mapView.animate(toBearing: CLLocationDirection((self.getHeadingForDirection(fromCoordinate: self.pickUpMarker.position, toCoordinate: self.dropOffMarker.position) + 100) ))
关于ios - Gmsmap 快速旋转 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52620339/
在这张图片中GMSMapView有两个标记 Green marker is pickup location and Red marker is drop location marker 我想根据拾取位
我的应用程序使用 GMSMap 在 map 上显示一些位置,用户可以打开 Yandex Navi、Google map 应用程序以及 Apple map 来导航选定的 poi。仅列出已安装的应用程序以
我正在使用谷歌地图,并且我使用了 GMS map View 。在 map View 中,我为当前位置创建了一个 GMS 标记,它每隔一秒更新一次当前的纬度和经度值。我使用了以下代码: mMapVie
我正在尝试在适用于 iOS6 的 Google map View 中加载地点。如何设置 map 的框架?目前是全屏 -(void)loadView { GMSCameraPosition *c
我是一名优秀的程序员,十分优秀!