Search code examples
google-mapsgoogle-maps-api-3google-street-viewphotosphere

How to get linked panoId for google Photo Sphere?


I'm having hard time to find linked panoId form a given Photo Sphere panoid.

If it is a google see insides i am getting the linked panoId by using this API

http://cbk0.google.com/cbk?output=xml&panoid=<PANO ID>

But in case of Photo Sphere this API is not returning the XML data. Can any one help me out with this problem.

see insides Pano ID = "enEZO0FuPFAAAAQvxYdP0w"

Photo Sphere Pano ID = "F:-fr8FidB2CSQ/V49sgVq8pHI/AAAAAAAABFw/bMktS2vh6mcQtQB6y1-vBXTPTZCCnxTbQCLIB"


Solution

  • The URL http://cbk0.google.com/cbk?output=xml&panoid=<PANO ID> is not documented feature, you should be aware that Google Maps API Terms of Service prohibits to access imagery using undocumented channels. See paragraph 10.1(a) of ToS:

    No access to APIs or Content except through the Service. You will not access the Maps API(s) or the Content except through the Service. For example, you must not access map tiles or imagery through interfaces or channels (including undocumented Google interfaces) other than the Maps API(s).

    https://developers.google.com/maps/terms#section_10_1

    To access panorama data via service you should use API. For example, in Maps JavaScript API you can use StreetViewService class.

    Code snippet

    var panorama;
          function initialize() {
              var svService = new google.maps.StreetViewService();
              var panoRequest = {
                  pano: "F:-fr8FidB2CSQ/V49sgVq8pHI/AAAAAAAABFw/bMktS2vh6mcQtQB6y1-vBXTPTZCCnxTbQCLIB"
              };
            
              svService.getPanorama(panoRequest, function(panoData, status){
                  if (status === google.maps.StreetViewStatus.OK) {
                      panorama = new google.maps.StreetViewPanorama(
                          document.getElementById('street-view'),
                          {
                              pano: panoData.location.pano,
                              pov: {
                                  heading: 10,
                                  pitch: 10
                              }
                          });
                       console.log(panoData);
                  } else {
                      //Handle other statuses here
                  }
              });
          }
    html, body {
       height: 100%;
       margin: 0;
       padding: 0;
    }
    #street-view {
       height: 100%;
    }
    <div id="street-view"></div>
    <script async defer
             src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDztlrk_3CnzGHo7CFvLFqE_2bUKEq1JEU&callback=initialize">
        </script>

    Exists also Street View Image Metadata web service, but currently it doesn't work with Photo Spheres.

    There is a bug in the public issue tracker:

    https://issuetracker.google.com/issues/35831151

    However, Google didn't expose any ETA on when or if it might be fixed. You can star the public issue to add your vote.

    UPDATE

    Recently, Google enabled access to PhotoSpheres via Street View Image API. Although, the pano ID format has changed.

    The F:-fr8FidB2CSQ/V49sgVq8pHI/AAAAAAAABFw/bMktS2vh6mcQtQB6y1-vBXTPTZCCnxTbQCLIB is now CAMSSi1mcjhGaWRCMkNTUS9WNDlzZ1ZxOHBISS9BQUFBQUFBQUJGdy9iTWt0UzJ2aDZtY1F0UUI2eTEtdkJYVFBUWkNDbnhUYlFDTElC

    Please look at my answer for more details.