Street View Side-By-Side Stay organized with collections Save and categorize content based on your preferences.
Page Summary
This example demonstrates how to display a Street View panorama alongside a map, showcasing the location and viewpoint.
The map and Street View are synchronized, with the map reflecting the position and orientation of the Street View.
Users can explore the provided code samples in TypeScript, JavaScript, CSS, and HTML to understand the implementation.
Links are available to try the sample on JSFiddle or Google Cloud Shell, or to clone and run it locally with Git and Node.js.
This example displays the Street View for a location alongside a map. The mapdisplays the position and point of view shown in the Street View window.
Read thedocumentation.
TypeScript
functioninitialize(){constfenway={lat:42.345573,lng:-71.098326};constmap=newgoogle.maps.Map(document.getElementById("map")asHTMLElement,{center:fenway,zoom:14,});constpanorama=newgoogle.maps.StreetViewPanorama(document.getElementById("pano")asHTMLElement,{position:fenway,pov:{heading:34,pitch:10,},});map.setStreetView(panorama);}declareglobal{interfaceWindow{initialize:()=>void;}}window.initialize=initialize;
JavaScript
functioninitialize(){constfenway={lat:42.345573,lng:-71.098326};constmap=newgoogle.maps.Map(document.getElementById("map"),{center:fenway,zoom:14,});constpanorama=newgoogle.maps.StreetViewPanorama(document.getElementById("pano"),{position:fenway,pov:{heading:34,pitch:10,},},);map.setStreetView(panorama);}window.initialize=initialize;
CSS
html,body{height:100%;margin:0;padding:0;}#map,#pano{float:left;height:100%;width:50%;}
HTML
<html> <head> <title>Street View split-map-panes</title> <link rel="stylesheet" type="text/css" href="./style.css" /> <script type="module" src="./index.js"></script> </head> <body> <div></div> <div></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=initialize&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-simplehttps://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-18 UTC.