setMaxAnimationFps

open fun setMaxAnimationFps(maxAnimationFps: Int)

Set max FPS at which location animators can output updates. The throttling will only impact the location puck and camera tracking smooth animations.

Setting this will not impact any other animations schedule with MapboxMap, gesture animations or zoomWhileTracking/tiltWhileTracking.

Use this setting to limit animation rate of the location puck on higher zoom levels to decrease the stress on the device's CPU which can directly improve battery life, without sacrificing UX.

Example usage:


mapboxMap.addOnCameraIdleListener(new MapboxMap.OnCameraIdleListener() {
  {@}Override
  public void onCameraIdle() {
    double zoom = mapboxMap.getCameraPosition().zoom;
    int maxAnimationFps;
    if (zoom < 5) {
      maxAnimationFps = 3;
    } else if (zoom < 10) {
      maxAnimationFps = 5;
    } else if (zoom < 15) {
      maxAnimationFps = 7;
    } else if (zoom < 18) {
      maxAnimationFps = 15;
    } else {
      maxAnimationFps = Integer.MAX_VALUE;
    }
    locationComponent.setMaxAnimationFps(maxAnimationFps);
  }
});

If you're looking for a way to throttle the FPS of the whole map, including other animations and gestures, see setMaximumFps.

Parameters

maxAnimationFps

max location animation FPS