Custom Street View Panoramas Stay organized with collections Save and categorize content based on your preferences.
Page Summary
This example demonstrates how to create a custom Street View panorama using the Google Maps JavaScript API.
It showcases a custom panorama of the Google Sydney office without using a map or default Street View imagery.
The code defines functions to fetch custom panorama tiles and construct StreetViewPanoramaData.
Both TypeScript and JavaScript code snippets are provided, with the JavaScript version compiled from TypeScript.
You can explore the sample interactively through JSFiddle or Google Cloud Shell, or clone the repository to run it locally.
This example displays a custom panorama of the Google Sydney office. Note thatthis example doesn't use a map or default Street View imagery.
Read thedocumentation.
TypeScript
functioninitPano(){// Set up Street View and initially set it visible. Register the// custom panorama provider function. Set the StreetView to display// the custom panorama 'reception' which we check for below.constpanorama=newgoogle.maps.StreetViewPanorama(document.getElementById("map")asHTMLElement,{pano:"reception",visible:true});panorama.registerPanoProvider(getCustomPanorama);}// Return a pano image given the panoID.functiongetCustomPanoramaTileUrl(pano:string,zoom:number,tileX:number,tileY:number):string{return("https://developers.google.com/maps/documentation/javascript/examples/full/images/"+"panoReception1024-"+zoom+"-"+tileX+"-"+tileY+".jpg");}// Construct the appropriate StreetViewPanoramaData given// the passed pano IDs.functiongetCustomPanorama(pano:string):google.maps.StreetViewPanoramaData{if(pano==="reception"){return{location:{pano:"reception",description:"Google Sydney - Reception",},links:[],// The text for the copyright control.copyright:"Imagery (c) 2010 Google",// The definition of the tiles for this panorama.tiles:{tileSize:newgoogle.maps.Size(1024,512),worldSize:newgoogle.maps.Size(2048,1024),// The heading in degrees at the origin of the panorama// tile set.centerHeading:105,getTileUrl:getCustomPanoramaTileUrl,},};}// @ts-ignore TODO fix typingsreturnnull;}declareglobal{interfaceWindow{initPano:()=>void;}}window.initPano=initPano;
JavaScript
functioninitPano(){// Set up Street View and initially set it visible. Register the// custom panorama provider function. Set the StreetView to display// the custom panorama 'reception' which we check for below.constpanorama=newgoogle.maps.StreetViewPanorama(document.getElementById("map"),{pano:"reception",visible:true},);panorama.registerPanoProvider(getCustomPanorama);}// Return a pano image given the panoID.functiongetCustomPanoramaTileUrl(pano,zoom,tileX,tileY){return("https://developers.google.com/maps/documentation/javascript/examples/full/images/"+"panoReception1024-"+zoom+"-"+tileX+"-"+tileY+".jpg");}// Construct the appropriate StreetViewPanoramaData given// the passed pano IDs.functiongetCustomPanorama(pano){if(pano==="reception"){return{location:{pano:"reception",description:"Google Sydney - Reception",},links:[],// The text for the copyright control.copyright:"Imagery (c) 2010 Google",// The definition of the tiles for this panorama.tiles:{tileSize:newgoogle.maps.Size(1024,512),worldSize:newgoogle.maps.Size(2048,1024),// The heading in degrees at the origin of the panorama// tile set.centerHeading:105,getTileUrl:getCustomPanoramaTileUrl,},};}// @ts-ignore TODO fix typingsreturnnull;}window.initPano=initPano;
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;}
HTML
<html> <head> <title>Custom Street View Panoramas</title> <link rel="stylesheet" type="text/css" href="./style.css" /> <script type="module" src="./index.js"></script> </head> <body> <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=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-custom-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-11 UTC.