Skip to main content

TdxCustomMapControl.ZoomToGeoRect(TdxMapControlGeoRect,Double) Method

Centers and zooms the map on a specified geographic rectangle, with optional padding around it.

Declaration

procedure ZoomToGeoRect(const ARect: TdxMapControlGeoRect; const APaddingFactor: Double); overload;

Parameters

Name Type
ARect TdxMapControlGeoRect
APaddingFactor Double

Remarks

This procedure does the following:

  • Centers the map on the center point of the geographic rectangle passed as the ARect parameter;

  • The first overloaded variant zooms the map in/out so that the rectangle almost entirely occupies the map area, with animation (if enabled).

  • The second overloaded variant of this procedure zooms the map in/out and adds padding around the rectangle based on rectangle dimensions and the padding factor passed as the APaddingFactor parameter. The padding factor is a Double value ranging from 0 inclusive to 1 exclusive.

The padding factor applies to the larger dimension of the rectangle and is divided by two for each side of the outside region along this dimension. In our example, the rectangle’s horizontal dimension (width) is larger than the vertical (height). The padding factor applies as follows.

When the vertical dimension is larger than the horizontal, the padding factor applies as follows.

The following image illustrates how the 0.3 padding factor (shortened to “PF”) applies to the horizontally oriented rectangle.

The first overloaded variant internally calls the second overloaded variant, passes 0 (zero) as the APaddingFactor parameter, and rounds down the resulting ZoomLevel property value so that the rectangle always fits the map area.

Note:The procedure does nothing if any of the following conditions are met:

  • The rectangle passed as the ARect parameter is incorrectly defined;

  • The padding factor passed as the APaddingFactor parameter is outside the acceptable range mentioned above.

See Also