setZoomLevel method
Sets the map zoom level centered on a specified screen position.
Changes the zoom level while keeping the specified screen position fixed, meaning the geographic location at that screen point remains at the same screen coordinates after zooming. The zoom level must be between minZoomLevel and maxZoomLevel.
If no screen position is provided, the zoom centers on the current cursor position (which defaults to viewport center). The operation can be animated by specifying a duration.
Parameters
zoomLevel: Target zoom level, must be between minZoomLevel and maxZoomLevelduration: Animation duration in milliseconds. Use0for instant zoom. Defaults to0screenPosition: Screen coordinates in physical pixels that should remain fixed during zoom, relative to the map view's top-left corner. Ifnull, uses the current cursor position. Defaults tonull
Returns
- On success: the previous zoom level. On error: error code (< 0)
See also:
zoomLevel- Get the current zoom level- canZoom - Check if zoom to level is possible
- setSlippyZoomLevel - Set zoom using slippy tile level
Implementation
int setZoomLevel(
final int zoomLevel, {
final int duration = 0,
final Point<int>? screenPosition,
}) {
final OperationResult resultString = objectMethod(
_pointerId,
'MapView',
'setZoomLevel',
args: <String, Object>{
'zoomLevel': zoomLevel,
'duration': duration,
if (screenPosition != null) 'xy': XyType<int>.fromPoint(screenPosition),
},
);
return resultString['result'];
}