Custom Street View Panorama Tiles Stay organized with collections Save and categorize content based on your preferences.
Page Summary
This example showcases the use of custom Street View panoramas by adding a link to a panorama inside the Google Sydney office from a Street View outside the office.
It demonstrates how to register a custom panorama provider and use the
links_changedevent to add a navigation link to the custom panorama.The custom panorama uses its own tile images, loaded using a
getTileUrlfunction within theStreetViewPanoramaDataobject.
This example displays a Street View outside of the Google Sydney office. It addsanother arrow to the image, in addition to the default Street View navigationarrows, that points into Google Sydney and links to a custom panorama.
Read thedocumentation.
TypeScript
letpanorama:google.maps.StreetViewPanorama;// StreetViewPanoramaData of a panorama just outside the Google Sydney office.letoutsideGoogle:google.maps.StreetViewPanoramaData;// StreetViewPanoramaData for a custom panorama: the Google Sydney reception.functiongetReceptionPanoramaData():google.maps.StreetViewPanoramaData{return{location:{pano:"reception",// The ID for this custom panorama.description:"Google Sydney - Reception",latLng:newgoogle.maps.LatLng(-33.86684,151.19583),},links:[{heading:195,description:"Exit",pano:(outsideGoogle.locationasgoogle.maps.StreetViewLocation).pano,},],copyright:"Imagery (c) 2010 Google",tiles:{tileSize:newgoogle.maps.Size(1024,512),worldSize:newgoogle.maps.Size(2048,1024),centerHeading:105,getTileUrl:function(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");},},};}functioninitPanorama(){panorama=newgoogle.maps.StreetViewPanorama(document.getElementById("street-view")asHTMLElement,{pano:(outsideGoogle.locationasgoogle.maps.StreetViewLocation).pano});// Register a provider for the custom panorama.panorama.registerPanoProvider((pano:string):google.maps.StreetViewPanoramaData=>{if(pano==="reception"){returngetReceptionPanoramaData();}// @ts-ignore TODO fix typingsreturnnull;});// Add a link to our custom panorama from outside the Google Sydney office.panorama.addListener("links_changed",()=>{if(panorama.getPano()===(outsideGoogle.locationasgoogle.maps.StreetViewLocation).pano){panorama.getLinks().push({description:"Google Sydney",heading:25,pano:"reception",});}});}functioninitMap():void{// Use the Street View service to find a pano ID on Pirrama Rd, outside the// Google office.newgoogle.maps.StreetViewService().getPanorama({location:{lat:-33.867386,lng:151.195767}}).then(({data}:google.maps.StreetViewResponse)=>{outsideGoogle=data;initPanorama();});}declareglobal{interfaceWindow{initMap:()=>void;}}window.initMap=initMap;
JavaScript
letpanorama;// StreetViewPanoramaData of a panorama just outside the Google Sydney office.letoutsideGoogle;// StreetViewPanoramaData for a custom panorama: the Google Sydney reception.functiongetReceptionPanoramaData(){return{location:{pano:"reception",// The ID for this custom panorama.description:"Google Sydney - Reception",latLng:newgoogle.maps.LatLng(-33.86684,151.19583),},links:[{heading:195,description:"Exit",pano:outsideGoogle.location.pano,},],copyright:"Imagery (c) 2010 Google",tiles:{tileSize:newgoogle.maps.Size(1024,512),worldSize:newgoogle.maps.Size(2048,1024),centerHeading:105,getTileUrl:function(pano,zoom,tileX,tileY){return("https://developers.google.com/maps/documentation/javascript/examples/full/images/"+"panoReception1024-"+zoom+"-"+tileX+"-"+tileY+".jpg");},},};}functioninitPanorama(){panorama=newgoogle.maps.StreetViewPanorama(document.getElementById("street-view"),{pano:outsideGoogle.location.pano},);// Register a provider for the custom panorama.panorama.registerPanoProvider((pano)=>{if(pano==="reception"){returngetReceptionPanoramaData();}// @ts-ignore TODO fix typingsreturnnull;});// Add a link to our custom panorama from outside the Google Sydney office.panorama.addListener("links_changed",()=>{if(panorama.getPano()===outsideGoogle.location.pano){panorama.getLinks().push({description:"Google Sydney",heading:25,pano:"reception",});}});}functioninitMap(){// Use the Street View service to find a pano ID on Pirrama Rd, outside the// Google office.newgoogle.maps.StreetViewService().getPanorama({location:{lat:-33.867386,lng:151.195767}}).then(({data})=>{outsideGoogle=data;initPanorama();});}window.initMap=initMap;
CSS
html,body{height:100%;margin:0;padding:0;}#street-view{height:100%;}
HTML
<html> <head> <title>Custom Street View Panorama Tiles</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=initMap&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-tileshttps://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.