Rotate GMSMarker in direction at which user facing

前端 未结 8 1177
独厮守ぢ
独厮守ぢ 2020-12-28 17:58

I have requirement like on my current location one view will display. It will rotate if device was rotate or location will be change.I research lot but got all the code whic

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-28 18:52

    you can do something like -

    -(void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading {
    
        CLLocationDirection direction = newHeading.trueHeading;
        lastDriverAngleFromNorth = direction;
        self.driverMarker.rotation = lastDriverAngleFromNorth - mapBearing;
    }
    
    #pragma mark - GMSMapViewDelegate
    
    - (void)mapView:(GMSMapView *)mapView didChangeCameraPosition:(GMSCameraPosition *)position {
    
        mapBearing = position.bearing;
        self.driverMarker.rotation = lastDriverAngleFromNorth - mapBearing;
    }
    

提交回复
热议问题