Hi.

I have an existing GLatLng , and a distance, and I want to set a new
point. I'm using an algorithm I found at 
http://www.movable-type.co.uk/scripts/latlong.html,
but I cannot get it to work, i've tried different variations of it all
day, but I can't get it to work. This is my current effort:

var R = 6371;
var radius = document.getElementById("radius").value;
var d=parseFloat(radius);
var lat1 = point1.lat() * Math.PI / 180;
var lon1 = point1.lng() * Math.PI / 180;
var brng = 60 * Math.PI / 180;
var lat2 = Math.asin( Math.sin(lat1)*Math.cos(d/R) +
                                Math.cos(lat1)*Math.sin(d/R)*Math.cos
(brng) );
var lon2 = lon1 + Math.atan2(Math.sin(brng)*Math.sin(d/R)*Math.cos
(lat1),
                                       Math.cos(d/R)-Math.sin(lat1)
*Math.sin(lat2));
lon2 = (lon2+Math.PI)%(2*Math.PI) - Math.PI;
if (!isNaN(lat2) || !isNaN(lon2)){
  marker2.setLatLng(new GLatLng(lat2,lon2));
  point2 = marker2.getLatLng();
  drawCircle(point1, point2, fillColour, fillColour);
}

The site can be found here:

http://22.latest.mapcircle.appspot.com/

(First pick to points, then change the radius to see the code in
action)

Any help really apreaciated.

Thanks!

Odd-R.

--

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.


Reply via email to