You can calculate the heading (bearing) between 2 lat lng points. I
find this page helpful: http://www.movable-type.co.uk/scripts/latlong.html
Here's my JavaScript translation:
/**
* @param {google.maps.LatLng} newLatLng
* @returns {number}
*/
google.maps.LatLng.prototype.bearingTo = function (newLatLng) {
var lat1 = this.lat() * Math.PI / 180.0;
var lat2 = newLatLng.lat() * Math.PI / 180.0;
var lngDiff = (newLatLng.lng() - this.lng()) * Math.PI / 180.0;
var y = Math.sin(lngDiff) * Math.cos(lat2);
var x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) *
Math.cos(lat2) * Math.cos(lngDiff);
return ((Math.atan2(y, x) * 180 / Math.PI) + 360) % 360;
}
Chad Killingsworth
On Jun 7, 10:17 am, volksman <[email protected]> wrote:
> Hello All!
>
> I'm wondering if there is a way to get 'heading' information from a
> street address. My maps feature specific street addresses and I'm
> creating a custom control to allow people to see the address at street
> level. But right now when they hit the control it just drops them in
> a street view but heading north.
>
> I get my Lat/Long from the geocoding service. Was wondering if there
> is a way to get heading info from that service too.
>
> I don't see any mention of it in the docs. Am I blind?
>
> Thanks in advance!
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.