GMSMapView tracking mode heading

六眼飞鱼酱① 提交于 2020-01-03 05:41:08

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/38208747/gmsmapview-tracking-mode-heading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!