Skip to main content

StreetViewControl

The StreetViewControl object is used to configure the Street View control on the map.

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

See the Map Controls guide page for more information.

Example usage

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

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

Creating the StreetViewControl object

G.streetViewControl(options?: StreetViewControlValue): StreetViewControl

There are a few ways to setup the StreetViewControl object.

Pass no value.

G.streetViewControl(): StreetViewControl

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

Pass a boolean value to disable the Street View control.

G.streetViewControl(value: boolean): StreetViewControl

ParameterTypeRequiredDescription
valuebooleanYesWhether to enable the Street View control.

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

const control = G.streetViewControl(false);

Pass an object of options.

G.streetViewControl(options: StreetViewControlOptions): StreetViewControl

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

Pass an existing StreetViewControl object.

G.streetViewControl(value: StreetViewControl): StreetViewControl

ParameterTypeRequiredDescription
valueStreetViewControlYesThe existing StreetViewControl object.
const control = G.streetViewControl(existingStreetViewControlObject);

Street View Control options

Type StreetViewControlOptions.

StreetViewControlOptions is an object containing the configuration options for the StreetViewControl object.

OptionTypeDefaultDescription
enabledbooleantrueWhether the Street View control is enabled and will display on the map.
positionControlPositionINLINE_END_BLOCK_ENDThe display position of the control.
sourcesStreetViewSource | StreetViewSource[][StreetViewSource.DEFAULT]The sources for the street view.

Properties

PropertyTypeDescription
enabledbooleanWhether the Street View control is enabled and will display on the map.
positionControlPositionThe display position of the control.
sourcesStreetViewSource[]The sources for the street view.

Methods

disable

disable(): StreetViewControl

Disables and hides the Street View control.

control.disable();

enable

enable(): StreetViewControl

Enables and shows the Street View control.

control.enable();

setPosition

setPosition(position: ControlPosition): StreetViewControl

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)

setSources

setSources(sources: StreetViewSourceValue | StreetViewSourceValue[]): StreetViewControl

Set the sources for the street view control.

ParameterTypeRequiredDescription
sourcesStreetViewSource | StreetViewSource[]YesThe sources of the control.
// The following are equivalent
control.setSource(G.StreetViewSource.GOOGLE);
control.setSource([G.StreetViewSource.GOOGLE)];

toGoogle

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

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

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