getOptimalRoutesCenterViewport method

Rectangle<int> getOptimalRoutesCenterViewport(
  1. List<Route> routes, {
  2. Rectangle<int>? screenRect,
})

Gets the highlighted items optimal center viewport given the user custom input.

The returned viewport is adjusted so all highlighted information will be visible

The user can use this as the input to centerOnArea

Parameters

  • IN routes Route list to be shown.
  • IN screenRect Screen viewport rectangle where routes should be centered. If empty, then the whole viewport will be used.

Returns

  • The adjusted viewport. The coordinates are relative to view parent screen

Implementation

Rectangle<int> getOptimalRoutesCenterViewport(
  final List<Route> routes, {
  final Rectangle<int>? screenRect,
}) {
  final OperationResult resultString = objectMethod(
    _pointerId,
    'MapView',
    'getOptimalRoutesCenterViewport',
    args: <String, dynamic>{
      'routesList': RouteList.fromList(routes).pointerId,
      if (screenRect != null)
        'viewRc': RectType<int>.fromRectangle(screenRect),
    },
  );

  final Rectangle<int> rect = Rectangle<int>(
    resultString['result']['x'] ?? 0,
    resultString['result']['y'] ?? 0,
    resultString['result']['width'] ?? 0,
    resultString['result']['height'] ?? 0,
  );

  return rect;
}