Hi i have two google map coordinates...
point 1: "1.326631,103.861297" and point 2: "1.326116,103.860873".
Is there any way to do a javascript function to tell whether point 1 & 2 is near to each other probably by through a r开发者_运维问答adius circle? Thanks
Here are the calculations, I wrote a function in SQL for calculating radial miles from two points based on latitude and longitude. You could probably use it as a basis for converting it to Javascript if needed.
declare @DegToRad as float
declare @Ans as float
declare @Miles as float
set @DegToRad = 57.29577951
set @Ans = 0
set @Miles = 0
set @Ans = SIN(@lat1 / @DegToRad) * SIN(@lat2 / @DegToRad) + COS(@lat1 / @DegToRad ) * COS( @lat2 / @DegToRad ) * COS(ABS(@long2 - @long1 )/@DegToRad)
set @Miles = 3959 * ATAN(SQRT(1 - SQUARE(@Ans)) / @Ans)
set @Miles = CEILING(@Miles)
return @Miles
Edit: By the way, there's a good open source control that you can use in ASP.net on Codeplex.
http://googlemap.codeplex.com/
精彩评论