title: How to check if a LatLng is valid in Google StreetView using JS and PHP
body: <p>I am trying to implement a php service that will take a <code>$_GET("LAT")</code> and a <code>$_GET("LNG")</code> and verify it against the Google StreetView API <strong>v3</strong> JavaScript if it is valid or not.
  If it is, it returns OK, or NOK.</p>
  
  <p>I realize the JS code to accomplish that is:</p>
  
  <pre><code>var latLng = new google.maps.LatLng(12.121221, 78.121212);
              streetViewService.getPanoramaByLocation(latLng, STREETVIEW_MAX_DISTANCE, function (streetViewPanoramaData, status) {
                  if (status === google.maps.StreetViewStatus.OK) {
                      //ok
                  } else {
                      //no ok
                  }
              });
  </code></pre>
  
  <p>I am not being able though to tie everything together, meaning the PHP and JS, so that will work.</p>
  
  <p>Can anyone please help me?</p>
  
  <p>Thanks</p>
  
  <p><strong>EDIT 1:</strong></p>
  
  <p>This is the code I came up for far, but it does not work:</p>
  
  <pre><code>&lt;?php 
  Header("content-type: application/javascript");
  ?&gt;
  &lt;html&gt;
      &lt;head&gt;  &lt;/head&gt;
      &lt;body onload="checkValid()"&gt;
          &lt;script src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=true"&gt;&lt;/script&gt;
  
          &lt;script language="text/javascript"&gt;
          function checkValid() {
              var streetViewService = new google.maps.StreetViewService();
              var STREETVIEW_MAX_DISTANCE = 100;
              var latLng = new google.maps.LatLng(&lt;?php $_GET("LAT") ?&gt;,&lt;?php $_GET("LNG") ?&gt;);
              streetViewService.getPanoramaByLocation(latLng, STREETVIEW_MAX_DISTANCE, function (streetViewPanoramaData, status) {
                  if (status === google.maps.StreetViewStatus.OK) {
                      alert('ok');
                  } else {
                      alert('not');
                  }
              });
              }
  
          &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>