title: Google Maps API: Randomized street view
body: <p>I have been working on some code with the google maps API. I'm trying to get a randomized street view location.</p>
  <p>First I get a randomized location and look for a possible panorama in the area, once It gets the &quot;OK&quot; I tried to take the location data and create a panorama with it. I expected it to generate a new panorama but I just got a black screen and when I console.logged the data.latlng I got undefined. I also had no errors in the console</p>
  <pre><code>    function generateRandomPoint()
      {
          var sv = new google.maps.StreetViewService();
          sv.getPanoramaByLocation(
              new google.maps.LatLng(Math.random()*180 - 90,Math.random()*360 - 180), 500,processSVData
              );
      }
      
      function processSVData(data, status) {
          if (status == google.maps.StreetViewStatus.OK) {
              console.log(&quot;EE&quot;);
              
              const panorama = new google.maps.StreetViewPanorama(
              document.getElementById(&quot;panoramamap&quot;),
                  {
                      position: data.latLng,
                          pov: {
                              heading: 34,
                              pitch: 10,
                      },
                      disableDefaultUI: true,
                  }
              );
              
        } else generateRandomPoint();
      }
        
        window.onload = function() {
          generateRandomPoint();
          console.log(&quot;E&quot;);
        }
  </code></pre>