The easiest thing to do is to draw a straight line all the way from your
starting point to the Qibla, rather than drawing a short line in the
same direction.
Listen for map "moveend" events, remove the line and draw a new one from
the new map.getCenter().
Once you know the GLatLng()s of the two endpoints you can calculate the
bearing like this:
var lat1 = from.latRadians();
var lon1 = from.lngRadians();
var lat2 = to.latRadians();
var lon2 = to.lngRadians();
var angle = - Math.atan2( Math.sin( lon1 - lon2 ) * Math.cos( lat2 ),
Math.cos( lat1 ) * Math.sin( lat2 ) - Math.sin( lat1 )
* Math.cos( lat2 ) * Math.cos( lon1 - lon2 ) );
if ( angle < 0.0 ) angle += Math.PI * 2.0;
angle = angle * 180.0 / Math.PI;
angle = angle.toFixed(2);
If you insist on having a short line in the specified direction, you can
use the EShapes extension to calculate the endpoint.
var endpoint = EOffsetBearing(map.getCenter(), dist, angle);
http://econym.org.uk/gmap/eshapes.htm
--
http://econym.org.uk/gmap
The Blackpool Community Church Javascript Team
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" 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-API?hl=en
-~----------~----~----~----~------~----~------~--~---