Foxtable(狐表)用户栏目专家坐堂 → 获取地点经纬度坐标


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

主题:获取地点经纬度坐标

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


加好友 发短信
等级:童狐 帖子:221 积分:2195 威望:0 精华:0 注册:2011/12/14 9:56:00
获取地点经纬度坐标  发帖心情 Post By:2022/11/3 10:56:00 [只看该作者]

    做个记录,大家需要的可以直接拿走,粘贴修改后直接使用。

Case "getjwd.html"
        Dim sb As New StringBuilder
        sb.AppendLine("<!doctype html>")
        sb.AppendLine("<html>")
        sb.AppendLine("<head>")
        sb.AppendLine("<meta charset='utf-8'>")
        sb.AppendLine("<meta http-equiv='X-UA-Compatible' c>")
        sb.AppendLine("<meta name='viewport' c>")
        sb.AppendLine("<title>鼠标拾取地图坐标</title>")
        sb.AppendLine("<link rel='stylesheet' href='https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css'/> ")
        sb.AppendLine("<script type='text/javascript' src = 'https://cache.amap.com/lbs/static/addToolbar.js'></script>")
        sb.AppendLine("</head>")
        sb.AppendLine("<style type='text/css'>")
        sb.AppendLine("html,body{")
        sb.AppendLine("width: 100%;")
        sb.AppendLine("height: 100%;")
        sb.AppendLine("margin: 0px;")
        sb.AppendLine("}")
        sb.AppendLine(".map{")
        sb.AppendLine("height: 100%;")
        sb.AppendLine("width: 100%;")
        sb.AppendLine("float: left;")
        sb.AppendLine("}")
        sb.AppendLine("</style>")
        sb.AppendLine("<body>")
        sb.AppendLine("<div id='container' class='map'></div>")
        sb.AppendLine("<div class='input-card'>")
        sb.AppendLine("<h4>左击获取经纬度:</h4>")
        sb.AppendLine("<div class='input-item'>")
        sb.AppendLine("<input type='text' read id='lnglat'>")
        sb.AppendLine("</div>")
        sb.AppendLine("</div>")
        sb.AppendLine("<script src='https://webapi.amap.com/maps?v=1.4.15&key=您申请的key值&plugin=AMap.Autocomplete'></script> ")
        sb.AppendLine("<script type = 'text/javascript'> ")
        sb.AppendLine("var map = new AMap.Map('container', {")
        sb.AppendLine("resizeEnable: true")
        sb.AppendLine(" });")
        sb.AppendLine("var xmlhttp;")
        sb.AppendLine("if (window.XMLHttpRequest)")
        sb.AppendLine("{")
        ' /  / IE7 + , Firefox, Chrome, Opera, Safari 浏览器执行代码
        sb.AppendLine("xmlhttp = new XMLHttpRequest();")
        sb.AppendLine("}")
        sb.AppendLine("else")
        sb.AppendLine("{")
        ' /  / IE6, IE5 浏览器执行代码
        sb.AppendLine("xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');")
        sb.AppendLine("}")
        sb.AppendLine(" map.on('click', function(e) {")
        sb.AppendLine(" console.log(e.lnglat.getLng() + ',' + e.lnglat.getLat())")
        sb.AppendLine(" document.getElementById('lnglat').value = e.lnglat.getLng() + ',' + e.lnglat.getLat()")
        sb.AppendLine("xmlhttp.onreadystatechange = Function()")
        sb.AppendLine("{")
        sb.AppendLine("if (xmlhttp.readyState == 4 && xmlhttp.status == 200)")
        sb.AppendLine("{")
        sb.AppendLine("alert(xmlhttp.responseText);")
        sb.AppendLine(" }")
        sb.AppendLine("}")
        sb.AppendLine("xmlhttp.open('GET', 'acceptjwd.htm?Lng = ' + e.lnglat.getLng() + ' & ' + 'Lat = ' + e.lnglat.getLat(), true);")
        sb.AppendLine("xmlhttp.send();")
        sb.AppendLine(" });")
        sb.AppendLine(" </script>")
        sb.AppendLine("</body>")
        sb.AppendLine("</html>")
        e.WriteString(sb.ToString)
    Case "acceptjwd.htm"
        
        'MessageBox.Show(e.PlainText)
        Dim sb As New StringBuilder
        sb.AppendLine("接收到的数据有:")
        For Each key As String In e.Values.Keys
            sb.AppendLine(key & ":" & e.Values(key))
        Next
        MessageBox.Show(sb.ToString)
        e.WriteString("数据获取成功!")

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


加好友 发短信
等级:四尾狐 帖子:804 积分:6891 威望:0 精华:0 注册:2017/8/31 12:07:00
  发帖心情 Post By:2022/11/3 11:00:00 [只看该作者]


 回到顶部