canZoom method

bool canZoom(
  1. int zoomLevel, {
  2. Point<int>? screenPosition,
})

Checks if zooming to a specified level is possible.

Determines whether the map can be zoomed to the given zoomLevel from its current state. This considers factors such as the current zoom level, map constraints, and any active animations or gestures.

If a screenPosition is provided, checks if zooming while keeping that screen point fixed is feasible. If no position is given, the check assumes zooming centered on the current cursor position.

Parameters

  • zoomLevel: Target zoom level to check
  • screenPosition: Screen coordinates in physical pixels to remain fixed during zoom, relative to the map view's top-left corner. If null, uses the current cursor position. Defaults to null

Returns

  • true if zooming to the specified level is possible, false otherwise

See also:

  • setZoomLevel - Set the zoom level
  • zoomLevel - Get the current zoom level

Implementation

bool canZoom(int zoomLevel, {Point<int>? screenPosition}) {
  final OperationResult resultString = objectMethod(
    _pointerId,
    'MapView',
    'canZoom',
    args: <String, Object>{
      'zoomLevel': zoomLevel,
      if (screenPosition != null) 'xy': XyType<int>.fromPoint(screenPosition),
    },
  );

  return resultString['result'];
}