I am struggling with the following problem and can not find any solution in the Goolge Maps API docs or in the net, therefore I will try to post my question here:
I was using Googles Static StreetView Image API, where you can pass as a location a long/lat or a string with a postal address. In my case I was always using the string approach that contains in most cases the address with a housenumber. I was astonished by the results of the returned image, which was in most cases perfectly oriented in the direction to the searched address.
Now I wanted to give the JavaScript API for StreetViews a try. It works perfectly fine with the only available interface for a location through specifing the address through long/lat values. Through the optional pov parameters the heading can be specified too. But in case you want to initialize the StreetView with a postal address with a housenumber you are lost with that API. The only way is to geocode the postal address to a long/lat value through the Geocoding API but with the handicap of loosing the heading information. As a final result the initial StreetView image was completely different oriented in such a case.
I checked again the Static StreetView Image API and found following comment to the heading member:
heading (optional): ... If no heading is specified, a value will be calculated that directs the camera towards the specified location, from the point at which the closest photograph was taken.
Is there anything I can do here? How can I find the perfect heading between the position of the made photo to the location I am looking for? It seems only Google can do this through some internal magic for the Static StreetView Image API.
Finding North Using Google Maps This means that, as long as your blue icon has a beam that points upwards, you're heading north. If it's pointing downwards, you're heading south, etc. To do this, tap the compass icon in the top-right corner of the Google Maps map view.
Probably the most noticeable change in the Maps JavaScript API v3 is the introduction of the google. maps namespace. The v2 API places all objects in the Global namespace by default, which can result in naming collisions. Within v3, all objects are located within the google.
"You have included the Google Maps JavaScript API multiple times on this page. This may cause unexpected errors." To fix this, please check in your settings if you've also set the Google Maps API in another plugin configuration.
1) Indeed geocode the postal address to a long/lat value, so you have the 'exact' location of the house.
2) Use streetViewService.getPanoramaByLocation to see if streetview is available, and the response will include the exact location where the streetview image was taken.
Now you can calculate the heading between both points (1 being 'the house', and 2 being 'the camera'). You can use the google.maps.geometry.spherical.computeHeading function for this - see https://developers.google.com/maps/documentation/javascript/geometry#Navigation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With