title: Get heading and pitch from pixels on Street View
body: <p>I think this is the best place for this question. </p>
  
  <p>I am trying to get the heading and pitch of any clicked point on an embedded Google Street View.</p>
  
  <p>The only pieces of information I know and can get are: </p>
  
  <ul>
  <li>The field of view (degrees)</li>
  <li>The center point's heading and pitch (in degrees) and x and y pixel position</li>
  <li>The x and y pixel position of the mouse click</li>
  </ul>
  
  <p>I've included here a screenshot with simplified measurements as an example:</p>
  
  <p><img src="https://i.stack.imgur.com/mxopf.png" alt="Screenshot with measurements"></p>
  
  <p>I initally just thought you could divide the field of view by the pixel width to get degrees per pixel, but it's more complicated, I think it has to do with projecting onto the inside of a sphere, where the camera is at the centre of the sphere?</p>
  
  <p>Bonus if you can tell me how to do the reverse too...</p>
  
  <p><strong>Clarification:</strong>
  The goal is not to move the view to the clicked point, but give information about a clicked point. The degrees per pixel method doesn't work because the viewport is not linear. </p>
  
  <p>THe values I have here are just examples, but the field of view can be bigger or smaller (from [0.something, 180], and the center is not fixed, it could be any value in the range [0, 360] and vertically [-90, 90]. The point [0, 0] is simply the heading (horizontal degrees) and pitch (vertical degrees) of the photogapher when the photo was taken, and doesn't really represent anything.</p>