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>
  • 相关阅读:
    剑指Offer_08_跳台阶
    剑指Offer_07_斐波那契数列
    HDU 4283 You Are the One
    1B. Spreadsheets
    1A Theatre Square
    HDU 2476 String painter(记忆化搜索, DP)
    LightOJ 1422 Halloween Costumes(记忆化搜索)
    POJ 1651 Multiplication PuzzleDP方法:
    POJ 2955 Brackets (区间DP)
    HDU 5452 Minimum Cut
  • 原文地址:https://www.cnblogs.com/sprinng/p/4933833.html
Copyright © 2011-2022 走看看