Stay organized with collections Save and categorize content based on your preferences.
This example displays a Street View panorama, alongside a window that tracks several types of data associated with Street View events. This data can be tracked to better understand the performance of the underlying StreetViewPanorama object.
/* * 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;}
Git and Node.js are required to run this sample locally. Follow these instructions to install Node.js and NPM. The following commands clone, install dependencies and start the sample application.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-20 UTC."],[[["\u003cp\u003eThis example demonstrates tracking Street View events to monitor the performance of the \u003ccode\u003eStreetViewPanorama\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003eThe sample code displays a Street View panorama alongside a panel that updates with real-time data like position, POV, and pano ID.\u003c/p\u003e\n"],["\u003cp\u003eUsers can interact with the panorama, and the associated data will be reflected in the panel.\u003c/p\u003e\n"],["\u003cp\u003eThe example utilizes event listeners like \u003ccode\u003epano_changed\u003c/code\u003e, \u003ccode\u003elinks_changed\u003c/code\u003e, \u003ccode\u003eposition_changed\u003c/code\u003e, and \u003ccode\u003epov_changed\u003c/code\u003e to capture and display relevant data.\u003c/p\u003e\n"]]],["The code initializes a Street View panorama and a data-tracking window. It utilizes `StreetViewPanorama`'s event listeners (`pano_changed`, `links_changed`, `position_changed`, `pov_changed`) to capture data. When triggered, these listeners update the data in the window with relevant information. The `links_changed` event dynamically populates a table with link data. CSS defines layout and styling for the panorama and data panel, and HTML provides the structural framework for the application.\n"],null,["This example displays a Street View panorama, alongside a window that tracks\nseveral types of data associated with Street View events. This data can be\ntracked to better understand the performance of the underlying\n[`StreetViewPanorama`](/maps/documentation/javascript/reference/street-view#StreetViewPanorama)\nobject.\n\nRead the\n[documentation](/maps/documentation/javascript/streetview#StreetViewEvents). \n\nTypeScript \n\n```typescript\nfunction initPano() {\n const panorama = new google.maps.StreetViewPanorama(\n document.getElementById(\"pano\") as HTMLElement,\n {\n position: { lat: 37.869, lng: -122.255 },\n pov: {\n heading: 270,\n pitch: 0,\n },\n visible: true,\n }\n );\n\n panorama.addListener(\"pano_changed\", () =\u003e {\n const panoCell = document.getElementById(\"pano-cell\") as HTMLElement;\n\n panoCell.innerHTML = panorama.getPano();\n });\n\n panorama.addListener(\"links_changed\", () =\u003e {\n const linksTable = document.getElementById(\"links_table\") as HTMLElement;\n\n while (linksTable.hasChildNodes()) {\n linksTable.removeChild(linksTable.lastChild as ChildNode);\n }\n\n const links = panorama.getLinks();\n\n for (const i in links) {\n const row = document.createElement(\"tr\");\n\n linksTable.appendChild(row);\n\n const labelCell = document.createElement(\"td\");\n\n labelCell.innerHTML = \"\u003cb\u003eLink: \" + i + \"\u003c/b\u003e\";\n\n const valueCell = document.createElement(\"td\");\n\n valueCell.innerHTML = links[i].description as string;\n linksTable.appendChild(labelCell);\n linksTable.appendChild(valueCell);\n }\n });\n\n panorama.addListener(\"position_changed\", () =\u003e {\n const positionCell = document.getElementById(\n \"position-cell\"\n ) as HTMLElement;\n\n (positionCell.firstChild as HTMLElement).nodeValue =\n panorama.getPosition() + \"\";\n });\n\n panorama.addListener(\"pov_changed\", () =\u003e {\n const headingCell = document.getElementById(\"heading-cell\") as HTMLElement;\n const pitchCell = document.getElementById(\"pitch-cell\") as HTMLElement;\n\n (headingCell.firstChild as HTMLElement).nodeValue =\n panorama.getPov().heading + \"\";\n (pitchCell.firstChild as HTMLElement).nodeValue =\n panorama.getPov().pitch + \"\";\n });\n}\n\ndeclare global {\n interface Window {\n initPano: () =\u003e void;\n }\n}\nwindow.initPano = initPano;https://github.com/googlemaps/js-samples/blob/2683f7366fb27829401945d2a7e27d77ed2df8e5/samples/streetview-events/index.ts#L8-L78\n```\n| **Note:** Read the [guide](/maps/documentation/javascript/using-typescript) on using TypeScript and Google Maps.\n\nJavaScript \n\n```javascript\nfunction initPano() {\n const panorama = new google.maps.StreetViewPanorama(\n document.getElementById(\"pano\"),\n {\n position: { lat: 37.869, lng: -122.255 },\n pov: {\n heading: 270,\n pitch: 0,\n },\n visible: true,\n },\n );\n\n panorama.addListener(\"pano_changed\", () =\u003e {\n const panoCell = document.getElementById(\"pano-cell\");\n\n panoCell.innerHTML = panorama.getPano();\n });\n panorama.addListener(\"links_changed\", () =\u003e {\n const linksTable = document.getElementById(\"links_table\");\n\n while (linksTable.hasChildNodes()) {\n linksTable.removeChild(linksTable.lastChild);\n }\n\n const links = panorama.getLinks();\n\n for (const i in links) {\n const row = document.createElement(\"tr\");\n\n linksTable.appendChild(row);\n\n const labelCell = document.createElement(\"td\");\n\n labelCell.innerHTML = \"\u003cb\u003eLink: \" + i + \"\u003c/b\u003e\";\n\n const valueCell = document.createElement(\"td\");\n\n valueCell.innerHTML = links[i].description;\n linksTable.appendChild(labelCell);\n linksTable.appendChild(valueCell);\n }\n });\n panorama.addListener(\"position_changed\", () =\u003e {\n const positionCell = document.getElementById(\"position-cell\");\n\n positionCell.firstChild.nodeValue = panorama.getPosition() + \"\";\n });\n panorama.addListener(\"pov_changed\", () =\u003e {\n const headingCell = document.getElementById(\"heading-cell\");\n const pitchCell = document.getElementById(\"pitch-cell\");\n\n headingCell.firstChild.nodeValue = panorama.getPov().heading + \"\";\n pitchCell.firstChild.nodeValue = panorama.getPov().pitch + \"\";\n });\n}\n\nwindow.initPano = initPano;https://github.com/googlemaps/js-samples/blob/2683f7366fb27829401945d2a7e27d77ed2df8e5/dist/samples/streetview-events/docs/index.js#L7-L64\n```\n| **Note:** The JavaScript is compiled from the TypeScript snippet.\n\nCSS \n\n```css\n/* \n * Always set the map height explicitly to define the size of the div element\n * that contains the map. \n */\n#map {\n height: 100%;\n}\n\n/* \n * Optional: Makes the sample page fill the window. \n */\nhtml,\nbody {\n height: 100%;\n margin: 0;\n padding: 0;\n}\n\n#floating-panel {\n position: absolute;\n top: 10px;\n left: 25%;\n z-index: 5;\n background-color: #fff;\n padding: 5px;\n border: 1px solid #999;\n text-align: center;\n font-family: \"Roboto\", \"sans-serif\";\n line-height: 30px;\n padding-left: 10px;\n}\n\n#pano {\n width: 50%;\n height: 100%;\n float: left;\n}\n\n#floating-panel {\n width: 45%;\n height: 100%;\n float: right;\n text-align: left;\n overflow: auto;\n position: static;\n border: 0px solid #999;\n}\nhttps://github.com/googlemaps/js-samples/blob/2683f7366fb27829401945d2a7e27d77ed2df8e5/dist/samples/streetview-events/docs/style.css#L7-L54\n```\n\nHTML \n\n```html\n\u003chtml\u003e\n \u003chead\u003e\n \u003ctitle\u003eStreet View Events\u003c/title\u003e\n\n \u003clink rel=\"stylesheet\" type=\"text/css\" href=\"./style.css\" /\u003e\n \u003cscript type=\"module\" src=\"./index.js\"\u003e\u003c/script\u003e\n \u003c/head\u003e\n \u003cbody\u003e\n \u003cdiv id=\"pano\"\u003e\u003c/div\u003e\n \u003cdiv id=\"floating-panel\"\u003e\n \u003ctable\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cb\u003ePosition\u003c/b\u003e\u003c/td\u003e\n \u003ctd id=\"position-cell\"\u003e \u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cb\u003ePOV Heading\u003c/b\u003e\u003c/td\u003e\n \u003ctd id=\"heading-cell\"\u003e270\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cb\u003ePOV Pitch\u003c/b\u003e\u003c/td\u003e\n \u003ctd id=\"pitch-cell\"\u003e0.0\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cb\u003ePano ID\u003c/b\u003e\u003c/td\u003e\n \u003ctd id=\"pano-cell\"\u003e \u003c/td\u003e\n \u003c/tr\u003e\n \u003ctable id=\"links_table\"\u003e\u003c/table\u003e\n \u003c/table\u003e\n \u003c/div\u003e\n\n \u003c!-- \n The `defer` attribute causes the script to execute after the full HTML\n document has been parsed. For non-blocking uses, avoiding race conditions,\n and consistent behavior across browsers, consider loading using Promises. See\n https://developers.google.com/maps/documentation/javascript/load-maps-js-api\n for more information.\n --\u003e\n \u003cscript\n src=\"https://maps.googleapis.com/maps/api/js?key=AIzaSyB41DRUbKWJHPxaFjMAwdrzWzbVKartNGg&callback=initPano&v=weekly\"\n defer\n \u003e\u003c/script\u003e\n \u003c/body\u003e\n\u003c/html\u003ehttps://github.com/googlemaps/js-samples/blob/2683f7366fb27829401945d2a7e27d77ed2df8e5/dist/samples/streetview-events/docs/index.html#L8-L51\n```\n\nTry Sample \n[JSFiddle.net](https://jsfiddle.net/gh/get/library/pure/googlemaps/js-samples/tree/master/dist/samples/streetview-events/jsfiddle) [Google Cloud Shell](https://ssh.cloud.google.com/cloudshell/editor?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fgooglemaps%2Fjs-samples&cloudshell_git_branch=sample-streetview-events&cloudshell_tutorial=cloud_shell_instructions.md&cloudshell_workspace=.)\n\nClone Sample\n\n\nGit and Node.js are required to run this sample locally. Follow these [instructions](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) to install Node.js and NPM. The following commands clone, install dependencies and start the sample application. \n\n git clone -b sample-streetview-events https://github.com/googlemaps/js-samples.git\n cd js-samples\n npm i\n npm start\n\n\nOther samples can be tried by switching to any branch beginning with `sample-`\u003cvar translate=\"no\"\u003eSAMPLE_NAME\u003c/var\u003e. \n\n git checkout sample-\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-nx\"\u003eSAMPLE_NAME\u003c/span\u003e\u003c/var\u003e\n npm i\n npm start"]]