简体   繁体   English

当用户进行交互时,如何使摄像机停止动画到更新位置?

[英]How can I make the camera stop animating to updatedLocation, when user interacts?

Imagine you are in a car right now and you are driving fast, so the camera follows the location and updates in seconds. 想象一下,您现在在车上,并且正在快速行驶,因此摄像头可以跟踪位置并在几秒钟内更新。 But if you would like to scroll and see other places on the map it doesn't work, because you will get instantly back to the updated Location. 但是,如果您想滚动查看地图上的其他地方,它将无法正常工作,因为您会立即返回到更新后的位置。

So that's why I am asking how to stop the camera from following the updated location when the user scrolls. 因此,这就是为什么我要问用户滚动时如何停止摄像机跟随更新的位置。 And in addition, I would also like that the camera starts following the current location again when the user presses the myLocationButton. 另外,我还希望当用户按下myLocationButton时,摄像头再次开始跟随当前位置。

follow this link and stop updating camera when you tap on map and start updating when you again tapped on my location 跟随此链接,当您点击地图时停止更新相机,并在再次点击我的位置时开始更新

https://developers.google.com/maps/documentation/ios-sdk/events https://developers.google.com/maps/documentation/ios-sdk/events

use this delegate method to reset the camera :- 使用此委托方法重置摄像机:-

public func didTapMyLocationButton(for mapView: GMSMapView) -> Bool {}

this can be used to stop camera if you are using marker 如果您使用标记器,可以用来停止相机

 func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
        self.mapview.selectedMarker =  marker
 return true
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM