GMSMapView跟踪模式标题 [英] GMSMapView tracking mode heading

查看:129
本文介绍了GMSMapView跟踪模式标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我使用 GMSMapView ,并且我想更改跟踪模式。在iOS MapKit中,我可以将跟踪模式更改为 MKUserTrackingModeFollowWithHeading ,但不知道如何在 GMSMapView $ b

在应用程序 Google Maps 中,它在第二次触摸 myLocationButton 。是否有可能?

解决方案

要连续更改当前位置的相机,您需要将Google地图的GMSCamera更新为当前位置。您可以在位置管理器委托方法中执行此操作。

  CLLocation * location; 

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
//从didUpdateLocation获取当前的经度和纬度
location = [locations lastObject] ;



$ b - (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];
//您可以将viewingAngle从0改为45
[self.mapForView animateToCameraPosition:camera];
}

如果您的委托没有被调用,请从我的答案此处



希望它有帮助。


In my app, I am using GMSMapView, and I would like to change tracking mode. In iOS MapKit, I can change the tracking mode to MKUserTrackingModeFollowWithHeading, but don't know how to change it in GMSMapView.

In the app Google Maps, it is working after second touch on myLocationButton. Is it possible?

解决方案

For continuously changing the camera with the current location, you will need to update the GMSCamera for google maps to current location. You can do it in Location Manager delegate method.

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];
}

In case your delegate is not getting called, take help from my answer here

Hope it helps.

这篇关于GMSMapView跟踪模式标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆