Foxtable(狐表)用户栏目专家坐堂 → 百度地图计算两点间直线距离,如何写代码?


  共有2552人关注过本帖树形打印复制链接

主题:百度地图计算两点间直线距离,如何写代码?

帅哥哟,离线,有人找我吗?
xluoping
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小狐 帖子:368 积分:3759 威望:0 精华:0 注册:2016/4/2 12:11:00
百度地图计算两点间直线距离,如何写代码?  发帖心情 Post By: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编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By: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)


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/11/14 9:01:00 [只看该作者]


 回到顶部