【问题标题】:GMSMapView tracking mode headingGMSMapView 跟踪模式航向
【发布时间】:2016-07-05 16:52:34
【问题描述】:

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

在应用程序Google Maps 中,它在第二次触摸myLocationButton 后工作。有可能吗?

【问题讨论】:

    标签: ios objective-c google-maps gmsmapview mkusertrackingmode


    【解决方案1】:

    为了不断改变当前位置的相机,您需要将谷歌地图的 GMSCamera 更新到当前位置。您可以在 Location Manager 委托方法中执行此操作。

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

    如果您的代表没有被叫到,请从我的回答 here 中寻求帮助

    希望对你有帮助。

    【讨论】:

    • 你不懂我的问题。
    • 打开谷歌地图应用,然后点击myLocation按钮,它会移动到你的位置,然后再次点击按钮,你会看到不同视角的地图(你可以用手机旋转)
    • 我已根据您的要求编辑了我的答案。请检查。
    • 很高兴我能帮上忙。 :)
    猜你喜欢
    • 1970-01-01
    • 2016-05-23
    • 2013-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-09
    • 1970-01-01
    • 2023-03-12
    相关资源
    最近更新 更多