简体   繁体   English

GMSMapView跟踪模式标题

[英]GMSMapView tracking mode heading

In my app, I am using GMSMapView , and I would like to change tracking mode. 在我的应用中,我正在使用GMSMapView ,并且我想更改跟踪模式。 In iOS MapKit, I can change the tracking mode to MKUserTrackingModeFollowWithHeading , but don't know how to change it in GMSMapView . 在iOS MapKit中,我可以将跟踪模式更改为MKUserTrackingModeFollowWithHeading ,但是不知道如何在GMSMapView进行更改。

In the app Google Maps , it is working after second touch on myLocationButton . 在应用程序Google Maps ,再次触摸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. 要使用当前位置连续更改相机,您需要将Google地图的GMSCamera更新到当前位置。 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. 希望能帮助到你。

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

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