Places UI Kit: A ready-to-use library that provides room for customization and low-code development. Try it out, and share yourinput on your UI Kit experience.

Street View Events

  • This example demonstrates tracking Street View events to monitor the performance of theStreetViewPanorama object.

  • The sample code displays a Street View panorama alongside a panel that updates with real-time data like position, POV, and pano ID.

  • Users can interact with the panorama, and the associated data will be reflected in the panel.

  • The example utilizes event listeners likepano_changed,links_changed,position_changed, andpov_changed to capture and display relevant data.

This example displays a Street View panorama, alongside a window that tracksseveral types of data associated with Street View events. This data can betracked to better understand the performance of the underlyingStreetViewPanoramaobject.

Read thedocumentation.

TypeScript

functioninitPano(){constpanorama=newgoogle.maps.StreetViewPanorama(document.getElementById("pano")asHTMLElement,{position:{lat:37.869,lng:-122.255},pov:{heading:270,pitch:0,},visible:true,});panorama.addListener("pano_changed",()=>{constpanoCell=document.getElementById("pano-cell")asHTMLElement;panoCell.innerHTML=panorama.getPano();});panorama.addListener("links_changed",()=>{constlinksTable=document.getElementById("links_table")asHTMLElement;while(linksTable.hasChildNodes()){linksTable.removeChild(linksTable.lastChildasChildNode);}constlinks=panorama.getLinks();for(constiinlinks){constrow=document.createElement("tr");linksTable.appendChild(row);constlabelCell=document.createElement("td");labelCell.innerHTML="<b>Link: "+i+"</b>";constvalueCell=document.createElement("td");valueCell.innerHTML=links[i].descriptionasstring;linksTable.appendChild(labelCell);linksTable.appendChild(valueCell);}});panorama.addListener("position_changed",()=>{constpositionCell=document.getElementById("position-cell")asHTMLElement;(positionCell.firstChildasHTMLElement).nodeValue=panorama.getPosition()+"";});panorama.addListener("pov_changed",()=>{constheadingCell=document.getElementById("heading-cell")asHTMLElement;constpitchCell=document.getElementById("pitch-cell")asHTMLElement;(headingCell.firstChildasHTMLElement).nodeValue=panorama.getPov().heading+"";(pitchCell.firstChildasHTMLElement).nodeValue=panorama.getPov().pitch+"";});}declareglobal{interfaceWindow{initPano:()=>void;}}window.initPano=initPano;
Note: Read theguide on using TypeScript and Google Maps.

JavaScript

functioninitPano(){constpanorama=newgoogle.maps.StreetViewPanorama(document.getElementById("pano"),{position:{lat:37.869,lng:-122.255},pov:{heading:270,pitch:0,},visible:true,},);panorama.addListener("pano_changed",()=>{constpanoCell=document.getElementById("pano-cell");panoCell.innerHTML=panorama.getPano();});panorama.addListener("links_changed",()=>{constlinksTable=document.getElementById("links_table");while(linksTable.hasChildNodes()){linksTable.removeChild(linksTable.lastChild);}constlinks=panorama.getLinks();for(constiinlinks){constrow=document.createElement("tr");linksTable.appendChild(row);constlabelCell=document.createElement("td");labelCell.innerHTML="<b>Link: "+i+"</b>";constvalueCell=document.createElement("td");valueCell.innerHTML=links[i].description;linksTable.appendChild(labelCell);linksTable.appendChild(valueCell);}});panorama.addListener("position_changed",()=>{constpositionCell=document.getElementById("position-cell");positionCell.firstChild.nodeValue=panorama.getPosition()+"";});panorama.addListener("pov_changed",()=>{constheadingCell=document.getElementById("heading-cell");constpitchCell=document.getElementById("pitch-cell");headingCell.firstChild.nodeValue=panorama.getPov().heading+"";pitchCell.firstChild.nodeValue=panorama.getPov().pitch+"";});}window.initPano=initPano;
Note: The JavaScript is compiled from the TypeScript snippet.

CSS

/* * Always set the map height explicitly to define the size of the div element * that contains the map. */#map{height:100%;}/* * Optional: Makes the sample page fill the window. */html,body{height:100%;margin:0;padding:0;}#floating-panel{position:absolute;top:10px;left:25%;z-index:5;background-color:#fff;padding:5px;border:1pxsolid#999;text-align:center;font-family:"Roboto","sans-serif";line-height:30px;padding-left:10px;}#pano{width:50%;height:100%;float:left;}#floating-panel{width:45%;height:100%;float:right;text-align:left;overflow:auto;position:static;border:0pxsolid#999;}

HTML

<html>  <head>    <title>Street View Events</title>    <link rel="stylesheet" type="text/css" href="./style.css" />    <script type="module" src="./index.js"></script>  </head>  <body>    <div></div>    <div>      <table>        <tr>          <td><b>Position</b></td>          <td>&nbsp;</td>        </tr>        <tr>          <td><b>POV Heading</b></td>          <td>270</td>        </tr>        <tr>          <td><b>POV Pitch</b></td>          <td>0.0</td>        </tr>        <tr>          <td><b>Pano ID</b></td>          <td>&nbsp;</td>        </tr>        <table></table>      </table>    </div>    <!--       The `defer` attribute causes the script to execute after the full HTML      document has been parsed. For non-blocking uses, avoiding race conditions,      and consistent behavior across browsers, consider loading using Promises. See      https://developers.google.com/maps/documentation/javascript/load-maps-js-api      for more information.      -->    <script      src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB41DRUbKWJHPxaFjMAwdrzWzbVKartNGg&callback=initPano&v=weekly"      defer    ></script>  </body></html>

Try Sample

Clone Sample

Git and Node.js are required to run this sample locally. Follow theseinstructions to install Node.js and NPM. The following commands clone, install dependencies and start the sample application.

gitclone-bsample-streetview-eventshttps://github.com/googlemaps/js-samples.gitcdjs-samplesnpminpmstart

Other samples can be tried by switching to any branch beginning withsample-SAMPLE_NAME.

gitcheckoutsample-SAMPLE_NAMEnpminpmstart

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.