Document Maps SDK for iOS Guides Controls and Gestures Controls

Controls

The iOS SDK provides three built-in map controls that help users understand the current map state: the map logo, the compass, and the scale bar.

Map Logo

By default, the map logo is hidden. You can control its visibility using the following method:

- (void)setOverSeaMapLogoShow:(BOOL)isShowLogo

Set isShowLogo to YES to display the overseas map logo.

Compass

The compass is enabled by default and appears in the upper-right corner of the map. Use the MAMapView.showsCompass property to control its visibility, and the compassOrigin property to change its position.

The following example toggles the compass visibility and sets its position in the viewDidLoad method of ViewController.m:

_mapView.showsCompass = YES;  // Set to NO to hide the compass; YES to show it
_mapView.compassOrigin = CGPointMake(_mapView.compassOrigin.x, 22);  // Set the compass position

Scale Bar

The scale bar is displayed by default in the upper-left corner of the map. The maximum scale is 1:10m, and the minimum scale is 1:1000km. Use the MAMapView.showsScale property to control its visibility, and the scaleOrigin property to change its position.

The following example toggles the scale bar visibility and sets its position in the viewDidLoad method of ViewController.m:

_mapView.showsScale = YES;  // Set to NO to hide the scale bar; YES to show it
_mapView.scaleOrigin = CGPointMake(_mapView.scaleOrigin.x, 22);  // Set the scale bar position

Set the Scale Unit

/// Enumeration for scale control units
/// @since 11.1.200
typedef NS_ENUM(NSInteger, MAScaleControlsUnit) {
    MAScaleControlsUnitMETRIC,    ///< Metric system
    MAScaleControlsUnitIMPERIAL   ///< Imperial system
};

/// Sets the unit used by the scale control.
/// @since 11.1.200
@property (nonatomic, assign) MAScaleControlsUnit scaleControlsUnit;

/// Sets the unit used by the scale control.
@property (nonatomic, assign) MAScaleControlsUnit unit;

/// Enumeration for scale display units
typedef NS_ENUM(NSInteger, MAScaleDisplayUnit) {
    MAScaleDisplayUnitMeter,       ///< Meter
    MAScaleDisplayUnitKilometer,   ///< Kilometer
    MAScaleDisplayUnitFoot,        ///< Foot
    MAScaleDisplayUnitMile         ///< Mile
};

After running the code, the map logo appears in the lower-right corner, and the compass and scale bar are no longer obstructed, as shown in the following image:

iOS map view showing the repositioned logo, compass, and scale bar controls after adjustment