Skip to main content

RotateControl

The RotateControl object is used to configure the Rotate control on the map.

The RotateControl object lets you change the position of the rotate control.

See the Map Controls guide page for more information.

Example usage

const rotateControl = G.rotateControl({
position: G.ControlPosition.LEFT_CENTER,
});

const map = G.map('map', {
center: [40.7128, -74.0060],
rotateControl: rotateControl,
});

Creating the RotateControl object

G.rotateControl(options?: RotateControlValue): RotateControl

There are a few ways to setup the RotateControl object.

Pass no value.

G.rotateControl(): RotateControl

const control = G.rotateControl();
control.position = G.ControlPosition.LEFT_CENTER;

Pass a boolean value to disable the Rotate control.

G.rotateControl(value: boolean): RotateControl

ParameterTypeRequiredDescription
valuebooleanYesWhether to enable the Rotate control.

If you pass a false value to the rotateControl method then that will disable and hide the Rotate control when this is associated with a map.

const control = G.rotateControl(false);

Pass an object of options.

G.rotateControl(options: RotateControlOptions): RotateControl

ParameterTypeRequiredDescription
optionsRotateControlOptionsYesThe configuration options.
const rotateControl = G.rotateControl({
position: G.ControlPosition.LEFT_CENTER,
});

Pass an existing RotateControl object.

G.rotateControl(value: RotateControl): RotateControl

ParameterTypeRequiredDescription
valueRotateControlYesThe existing RotateControl object.
const control = G.rotateControl(existingRotateControlObject);

Rotate Control options

Type RotateControlOptions.

RotateControlOptions is an object containing the configuration options for the RotateControl object.

OptionTypeDefaultDescription
enabledbooleantrueWhether the Rotate control is enabled and will display on the map.
positionControlPositionINLINE_END_BLOCK_STARTThe display position of the control.

Properties

PropertyTypeDescription
enabledbooleanWhether the Rotate control is enabled and will display on the map.
positionControlPositionThe display position of the control.

Methods

disable

disable(): RotateControl

Disables and hides the Rotate control.

control.disable();

enable

enable(): RotateControl

Enables and shows the Rotate control.

control.enable();

setPosition

setPosition(position: ControlPosition): RotateControl

Set the display position of the control on the map.

ParameterTypeRequiredDescription
positionControlPositionYesThe display position of the control.
control.setPosition(G.ControlPosition.BLOCK_END_INLINE_START)

toGoogle

toGoogle(): Promise<google.maps.RotateControlOptions>

Get the object to use to pass the RotateControl options to the Google Map instance.

control.toGoogle().then((options) => {
// Do something with the options
});