在我的应用程序中,我正在使用GMSMapView
,并且我想更改跟踪模式。在 iOS MapKit 中,我可以将跟踪模式更改为MKUserTrackingModeFollowWithHeading
,但不知道如何更改它GMSMapView
。
在应用程序Google Maps
中,它在第二次触摸后工作myLocationButton
。是否可以?
在我的应用程序中,我正在使用GMSMapView
,并且我想更改跟踪模式。在 iOS MapKit 中,我可以将跟踪模式更改为MKUserTrackingModeFollowWithHeading
,但不知道如何更改它GMSMapView
。
在应用程序Google Maps
中,它在第二次触摸后工作myLocationButton
。是否可以?
要使用当前位置不断更改相机,您需要将谷歌地图的 GMSCamera 更新到当前位置。您可以在位置管理器委托方法中执行此操作。
CLLocation *location;
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
//Get current latitude and longitude from didUpdateLocation
location = [locations lastObject];
}
-(void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:location.coordinate.latitude longitude:location.coordinate.longitude zoom:10 bearing:newHeading.trueHeading viewingAngle:0];
//You can change viewingAngle from 0 to 45
[self.mapForView animateToCameraPosition:camera];
}
如果您的代表没有被叫到,请从我的回答中获取帮助
希望能帮助到你。