startFollowingPosition method

void startFollowingPosition({
  1. GemAnimation? animation,
  2. int zoomLevel = -1,
  3. double? viewAngle,
  4. MapSceneObject? positionObj,
})

Activates follow position mode to track the current location.

Enables automatic camera tracking of the device's real or simulated position. The map continuously updates to keep the current position visible, with optional animation to the starting position. This mode disables the cursor if enabled and requires automatic map rendering.

Uses the positions provided by the PositionService. Ensure that the position service is started and providing updates before activating follow mode or start simulation on a route via the NavigationService.

Use the stopFollowingPosition method to exit follow mode and configure options with FollowPositionPreferences if needed. See MapSceneObject.getDefPositionTracker for customizing the navigation arrow appearance.

Parameters

  • animation: Animation settings for transitioning to follow mode. If null, starts instantly. Defaults to null
  • zoomLevel: Target zoom level when follow mode starts. Use -1 for automatic selection. Defaults to -1
  • viewAngle: Camera pitch angle in degrees (0-90), where 0 is top-down view and 90 is horizon view. If null, uses default angle. Defaults to null
  • positionObj: Custom MapSceneObject for the navigation arrow. If null, uses the SDK's default arrow. Defaults to null

See also:

Implementation

void startFollowingPosition({
  final GemAnimation? animation,
  final int zoomLevel = -1,
  final double? viewAngle,
  final MapSceneObject? positionObj,
}) {
  final bool hasViewAngle = viewAngle != null;

  objectMethod(
    _pointerId,
    'MapView',
    'startFollowingPosition',
    args: <String, Object>{
      if (animation != null) 'animation': animation,
      'zoomLevel': zoomLevel,
      'viewAngle': hasViewAngle ? viewAngle : -1,
      if (positionObj != null) 'positionObj': positionObj,
    },
  );
}