Skip to main content

ZoomControl

The ZoomControl object is used to configure the Zoom control on the map.

The ZoomControl object lets you change the position of the zoom control.

See the Map Controls guide page for more information.

Example usage

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

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

Creating the ZoomControl object

G.zoomControl(options?: ZoomControlValue): ZoomControl

There are a few ways to setup the ZoomControl object.

Pass no value.

G.zoomControl(): ZoomControl

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

Pass a boolean value to disable the Zoom control.

G.zoomControl(value: boolean): ZoomControl

ParameterTypeRequiredDescription
valuebooleanYesWhether to enable the Zoom control.

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

const control = G.zoomControl(false);

Pass an object of options.

G.zoomControl(options: ZoomControlOptions): ZoomControl

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

Pass an existing ZoomControl object.

G.zoomControl(value: ZoomControl): ZoomControl

ParameterTypeRequiredDescription
valueZoomControlYesThe existing ZoomControl object.
const control = G.zoomControl(existingZoomControlObject);

Zoom Control options

Type ZoomControlOptions.

ZoomControlOptions is an object containing the configuration options for the ZoomControl object.

OptionTypeDefaultDescription
enabledbooleantrueWhether the Zoom control is enabled and will display on the map.
positionControlPositionINLINE_END_BLOCK_ENDThe display position of the control.

Properties

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

Methods

disable

disable(): ZoomControl

Disables and hides the Zoom control.

control.disable();

enable

enable(): ZoomControl

Enables and shows the Zoom control.

control.enable();

setPosition

setPosition(position: ControlPosition): ZoomControl

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.ZoomControlOptions>

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

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