centerOnCoordinates method
- Coordinates coords, {
- int zoomLevel = -1,
- Point<
int> ? screenPosition, - GemAnimation? animation,
- double? mapAngle,
- double? viewAngle,
- double slippyZoomLevel = -1.0,
Centers the map view on specified WGS84 geographic coordinates.
Positions the map so the specified coords appear at the target screen
location with optional zoom level, rotation, and viewing angle adjustments.
If no screen position is specified, the coordinates center at the current
cursor position (defaulting to viewport center).
The operation can be animated using the animation parameter for smooth
transitions. Use skipAnimation to immediately complete any ongoing animation.
Parameters
coords: The WGS84 coordinates (latitude, longitude, optional altitude) to center onzoomLevel: Zoom level (higher values = more zoomed in). Use-1for automatic selection based on context. Defaults to-1screenPosition: Target screen position in physical pixels where the coordinates should project, relative to the map view's top-left corner. Ifnull, uses the current cursor position. Defaults tonullanimation: Animation settings for the centering operation. Ifnull, centering occurs instantly. Defaults tonullmapAngle: Map rotation angle in degrees (0-360), where 0 represents north-up alignment. Ifnull, rotation remains unchanged. Defaults tonullviewAngle: Camera pitch angle in degrees (0-90), where 0 is top-down view and 90 is horizon view. Ifnull, pitch remains unchanged. Defaults tonullslippyZoomLevel: Tile-based zoom level for specific tile system compatibility. Use-1.0for automatic selection. Defaults to-1.0
See also:
- centerOnArea - Center on a geographic area rectangle
- centerOnAreaRect - Center area within a specific screen rectangle
- skipAnimation - Stop ongoing animations
- transformWgsToScreen - Convert geographic to screen coordinates
Implementation
void centerOnCoordinates(
final Coordinates coords, {
final int zoomLevel = -1,
final Point<int>? screenPosition,
final GemAnimation? animation,
double? mapAngle,
double? viewAngle,
final double slippyZoomLevel = -1.0,
}) {
if (viewAngle != null && (viewAngle - viewAngle.toInt() == 0)) {
viewAngle -= 0.0000000001;
}
if (mapAngle != null && (mapAngle - mapAngle.toInt() == 0)) {
mapAngle -= 0.0000000001;
}
objectMethod(
_pointerId,
'MapView',
'centerOnCoordinates',
args: <String, Object>{
'coords': coords,
'zoomLevel': zoomLevel,
'slippyZoomLevel': slippyZoomLevel,
if (screenPosition != null) 'xy': XyType<int>.fromPoint(screenPosition),
if (animation != null) 'animation': animation,
if (mapAngle != null) 'mapAngle': mapAngle,
if (viewAngle != null) 'viewAngle': viewAngle,
},
);
}