Dim 纬度 As Double = 30.799173
Dim 经度 As Double = 120.781265
Dim ur As String = "http://api.map.baidu.com/geocoder/v2/?ak=hAaa2NLELKdAIfMhMjnuEgi1&output=json&location=" & 纬度 & "," & 经度
Dim hc As new HttpClient(ur)
Dim jo = JObject.Parse(hc.GetData)
output.show(jo.Tostring)
If jo("status") = 0 Then
'msgbox(jo("result")("addressComponent")("province")) '省份
'msgbox(jo("result")("addressComponent")("city")) '城市
'msgbox(jo("result")("addressComponent")("district")) '区域
msgbox(jo("result")("formatted_address")) '地理位置
End If
4.运行下面的代码,能向表中添加“类型”、“照片”,但不能添加“纬度”、"经度”(单精度小数),用字符型,运行时网页卡住不动,退出网页foxtable会提示:由于线程退出或应用程序请求,已中止 I/O 操作。
5.整个界面很丑,是否可以隐藏掉“获取经度纬度”、“纬度”、“经度”,这样比较简洁,或者“纬度”、“经度”不要保存了,我只要地理位置数据就可以了。
Case "hhh.htm" '首页
If e.PostValues.Count = 0 Then
wb.AddForm("","form1","hhh.htm")
wb.AppendHTML("<script src='http://res.wx.qq.com/open/js/jweixin-1.2.0.js'></script>",True) '引入JS-SDK库
wb.AppendHTML("<script src='./lib/jssdk2.js'></script>") '引入脚本文件
'在页面注入权限验证配置
Dim st As New Date(1970,1,1,8,0,0)
Dim appid As String = "wx4718459301f2db8f" '开发者ID
Dim timestamp As Integer = CInt((Date.Now - st).TotalSeconds()) '时间戳
Dim noncestr As String = Rand.NextString(16) '随机字符
Dim url As String = e.Request.URL.ToString '当前页面地址
Dim signature As String = Functions.Execute("GetJsSignature", noncestr, timestamp, url) '生成权限验证签名
Dim cfg As String = "wx.config({appId:'{0}',timestamp:{1},nonceStr:'{2}',signature:'{3}',jsApiList:['chooseImage']});"
wb.AppendHTML("<script>" & CExp(cfg,appid,timestamp,noncestr,signature) & "</script>",True)
'开始正常生成网页内容
With wb.AddInputGroup("form1","ipg1","打卡")
.AddSelect("类型","类型","|出发|抵达|离开|返厂")
.AddUploader("照片","照片",False) 'False表示,只允许上传一张照片
End With
With wb.AddButtonGroup("form1","btg1",False) '垂直排列
.Add("scan2","拍摄照片","button")
End With
wb.AppendHTML("<script src='./lib/jssdk1.js'></script>") '引入脚本文件
'在页面注入权限验证配置
Dim cfg2 As String = "wx.config({appId:'{0}',timestamp:{1},nonceStr:'{2}',signature:'{3}',jsApiList:['scanQRCode']});"
wb.AppendHTML("<script>" & CExp(cfg,appid,timestamp,noncestr,signature) & "</script>",True)
With wb.AddButtonGroup("form1","btg2",False) '垂直排列
.Add("scan1","获取经度纬度","button")
.Add("scan3","获取地址位置","button")
End With
With wb.AddInputGroup("form1","ipg2","地址位置")
.AddInput("纬度","纬度","text").Enabled = False
.AddInput("经度","经度","text").Enabled = False
With wb.AddInputGroup("form1","ipg3","位置")
.AddTextArea("wz",3).Enabled = False
End With
End With
With wb.AddButtonGroup("form1","btg3",True)
.Add("btn1", "确定", "submit")
End With
e.WriteString(wb.Build)
Else
Dim nms() As String = {"类型","照片","纬度","经度","位置"}
Dim dr As DataRow = DataTables("服务打卡").AddNew()
For Each nm As String In nms
dr(nm) = e.PostValues(nm)
Next
For Each key As String In e.Files.Keys
If key = "照片" Then
For Each fln As String In e.Files(key)
e.SaveFile(key, fln, ProjectPath & "Attachments\" & fln)
Next
dr.Lines("照片") = e.Files(key)
End If
Next
'保存并生成增加成功提示页面
e.WriteString(wb.Build)
End If