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
Parameter | Type | Required | Description |
---|---|---|---|
value | boolean | Yes | Whether 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
Parameter | Type | Required | Description |
---|---|---|---|
options | StreetViewControlOptions | Yes | The configuration options. |
const streetViewControl = G.streetViewControl({
position: G.ControlPosition.LEFT_CENTER,
});
Pass an existing StreetViewControl object.
G.streetViewControl(value: StreetViewControl): StreetViewControl
Parameter | Type | Required | Description |
---|---|---|---|
value | StreetViewControl | Yes | The 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.
Option | Type | Default | Description |
---|---|---|---|
enabled | boolean | true | Whether the Street View control is enabled and will display on the map. |
position | ControlPosition | INLINE_END_BLOCK_END | The display position of the control. |
sources | StreetViewSource | StreetViewSource[] | [StreetViewSource.DEFAULT] | The sources for the street view. |
Properties
Property | Type | Description |
---|---|---|
enabled | boolean | Whether the Street View control is enabled and will display on the map. |
position | ControlPosition | The display position of the control. |
sources | StreetViewSource[] | 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.
Parameter | Type | Required | Description |
---|---|---|---|
position | ControlPosition | Yes | The 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.
Parameter | Type | Required | Description |
---|---|---|---|
sources | StreetViewSource | StreetViewSource[] | Yes | The 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
});