StreetViewPanorama

Storybook

Open the StreetViewPanorama story

StreetViewPanorama shows an interactive Street View panorama in its own container. Position, point of view and zoom can be two-way bound.

Props

PropTypeDefaultDescription
positiongoogle.maps.LatLngLiteral | google.maps.LatLngPanorama position. Bindable: follows the user moving around.
povgoogle.maps.StreetViewPovCamera heading and pitch. Bindable: follows the user looking around.
zoomnumberZoom level. Bindable.
visiblebooleantrueWhether the panorama is visible.
optionsgoogle.maps.StreetViewPanoramaOptions (without position, pov, zoom, visible)Other panorama options.
idstringid of the container.
classstring''Class of the container.
stylestring'width:100%;height:100%;'Inline style of the container. The container needs a height.
panoramagoogle.maps.StreetViewPanorama | nullnullThe instance. Bindable: read it with bind:panorama.

Event Props

PropTypeDescription
onPanoChanged(pano: string) => voidpano_changed, with the panorama ID.
onStatusChanged(status) => voidstatus_changed, with the result of getStatus() ('OK', 'ZERO_RESULTS', ...).
onCloseClick() => voidcloseclick
onLoad(panorama: google.maps.StreetViewPanorama) => voidCalled once after the panorama is created.

Usage

<script lang="ts">
	import { APIProvider, StreetViewPanorama } from 'svelte-google-maps-api';

	let position = $state({ lat: 35.6595, lng: 139.7005 });
	let pov = $state({ heading: 165, pitch: 0 });
</script>

<div style="height: 400px;">
	<APIProvider apiKey="YOUR_API_KEY">
		<StreetViewPanorama bind:position bind:pov options={{ addressControl: false }} />
	</APIProvider>
</div>

<p>Heading: {Math.round(pov.heading)}°</p>
svelte

Notes

  • Use it directly inside APIProvider; it does not need (and should not be placed inside) GoogleMap.
  • The component loads the streetView library on demand.