zoukankan      html  css  js  c++  java
  • 腾讯地图api将物理地址转化成坐标

    <!DOCTYPE html>
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>地址解析</title>
        <style type="text/css">
            * {
                margin: 0px;
                padding: 0px;
            }
            body,
            button,
            input,
            select,
            textarea {
                font: 12px/16px Verdana, Helvetica, Arial, sans-serif;
            }
            p {
                width: 603px;
                padding-top: 3px;
                margin-top: 10px;
                overflow: hidden;
            }
            input#address {
                width: 300px;
            }
        </style>
        <script charset="utf-8" src="http://map.qq.com/api/js?v=2.exp"></script>
     
    </head>
     
    <body onload="init()">
        <script>
            var geocoder = null;
            var init = function() {
                geocoder = new qq.maps.Geocoder();
            }
                 
                function codeAddress() {
                    var address = document.getElementById("address").value;
                    //对指定地址进行解析
                    geocoder.getLocation(address);
                    //设置服务请求成功的回调函数
                    geocoder.setComplete(function(result) {
                        alert(result.detail.location);
                    });
                    //若服务请求失败,则运行以下函数
                    geocoder.setError(function() {
                        alert("出错了,请输入正确的地址!!!");
                    });
                }
        </script>
        <div>
            <input id="address" type="textbox" value="中国,北京,海淀区,海淀大街38号">
            <button onclick="codeAddress()">search</button>
        </div>
    </body>
     
    </html>
  • 相关阅读:
    应用部署架构演进【转载】
    TiDB 学习笔记一(运维管理)
    c++ strcmp函数
    C++ sort()函数
    C++ 遍历set的三种方式
    nvcc fatal : '--ptxas-options=-v': expected a number
    PAT A1039 Vector的使用
    C++ set
    C++ int与string互转换
    C++%f和%lf的区别
  • 原文地址:https://www.cnblogs.com/sprinng/p/4933833.html
Copyright © 2011-2022 走看看