# Calculating compass bearing between two GPS coordinates… with a twist [closed]

I'm building a virtual tour application that uses Google's streetview code to render the panoramas into a non-distorted view. Each panorama has 1 to n links where the user can select to move on.

I use the GPS coordinates of each location to calculate the compass bearing from the current location to the next. The issue has to do with StreetView's rendering of the link bearings.

When a panorama loads, one of the data fields required is centerHeading. This determines the part of the image that is rendered smack dab in the middle of whatever element you're using as a map container.

In addition, whatever value centerHeading has is what StreetView sees as due north. The link rendering locations are displayed relative to north, which causes quite a bit of inaccuracy with the link bearings.

Check out this for an example. The bearing from the start location to the next is 247 degrees, as calculated from the GPS coordinates of each location. Due to the way the image was taken, the centerHeading value is 175 degrees, and this throws off the actual links quite a bit. In order to have a correct link bearing, I have to manually replace the calculated bearing of 247 degrees with 0.

Multiply this trial and error bearing testing by over 100 seemingly arbitrary heading definitions, and you just might get a headache.

So my question is, is there a way to factor in the location's heading setting in the link bearing calculations?

-

## closed as unclear what you're asking by Martin F, Jason Scheirer, Devdatta Tengshe, Mapperz♦Mar 30 '15 at 14:26

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

its not clear from the app link. But I think your GPS coordinates are in lat/lon EPSG:4326 projection and google uses a different projection called Google Mercator. EPSG:900913 – rashad Nov 19 '12 at 4:59
Are you really asking about compass bearings -- from magnetic north? Or are you asking about geodetic bearings -- from true north? See [True to Grid bearing] (gis.stackexchange.com/q/61743/3195), [How to Calculate North] (gis.stackexchange.com/q/49747/3195), [calculate north direction] (gis.stackexchange.com/q/81962/3195), [True north, magnetic north and grid north] (gis.stackexchange.com/q/73302/3195). – Martin F Mar 17 '15 at 4:44