以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  百度地图计算两点间直线距离,如何写代码?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=127429)

--  作者:xluoping
--  发布时间:2018/11/14 8:26:00
--  百度地图计算两点间直线距离,如何写代码?
     var pointA = new BMap.Point(121.436043,29.294384); 
     var pointB = new BMap.Point(116.450111,39.927669); 

以上量点坐标,如何计算直线距离?精确到米


请帮助!!
         
以下是返回地址名称,就是按这样的格式写:如何写?

Dim e As RequestEventArgs = args(0)  \'网页函数开始   报位置的中文名称
Dim stt As String = e.PlainText
Dim nms() As String = stt.Split("|")
Dim jingdu  As Double = CDbl(nms(0))  \'经度
Dim weidu As Double = CDbl(nms(1))   \'纬度
Dim rqst As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://api.map.baidu.com/geocoder/v2/?ak=DD93be593f80a0ad6adc764c39625bd1&output=json&location=" & weidu & "," & jingdu)
Dim rsps As System.Net.HttpWebResponse = rqst.GetResponse
Dim stm As System.IO.Stream = rsps.GetResponseStream()
Dim reader As New System.IO.StreamReader(stm)
Dim json As String = reader.ReadToEnd
Dim ScriptControl As Object, data  As Object, JscriptCode As String
JscriptCode = "function toObject(json) {eval(""var o=""+json);return o;}"
ScriptControl = CreateObject("MSScriptControl.ScriptControl")
With ScriptControl
    .Language = "Javascript"
    .Timeout = -1
    .AddCode(JscriptCode)
    data = .Run("toObject", json)
End With
e.WriteString(data.result.formatted_address)
[此贴子已经被作者于2018/11/14 8:39:43编辑过]

--  作者:有点甜
--  发布时间:2018/11/14 8:55:00
--  

自己求

 

Dim x1 As Double = 37.856862
Dim y1 As Double = 112.525760
Dim x2 As Double = 37.857587
Dim y2 As Double = 112.525683


Dim rad As Double = 6371
Dim p1X As Double = X1 / 180 * Math.PI
Dim p1Y As Double = Y2 / 180 * Math.PI
Dim p2X As Double = X2 / 180 * Math.PI
Dim p2Y As Double = Y2 / 180 * Math.PI

Dim a As Double = p1X - p2X
Dim b As Double = p1Y - p2Y
Dim s As Double = 2 * Math.Asin(Math.Sqrt(Math.Pow(Math.Sin(a/2),2) + Math.Cos(p1X)*Math.Cos(p2X)*Math.Pow(Math.Sin(b/2),2))) * rad
output.show(s)


--  作者:有点甜
--  发布时间:2018/11/14 9:01:00
--  

或者看看

 

http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=83701&authorid=0&page=0&star=1