<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">

<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8" />
<script charset="utf-8" src="http://map.qq.com/api/js?v=2.exp"></script>
</head>
<body>
<input type="text" onblur="codeAddress(this.value)">
<input id = "lat" type = "text"><input id="lng" type="text" />
<script>
        var geocoder, map, marker = null;
   
        geocoder = new qq.maps.Geocoder();

        function codeAddress(address) {
            //var address = '中国,北京,海淀区,海淀大街38号';
            //对指定地址进行解析
            geocoder.getLocation(address);
            //设置服务请求成功的回调函数
            geocoder.setComplete(function(result) {
var arr = eval(result);

console.log(arr);
var location = arr.detail.location;

document.getElementById("lat").value=location.lat ;
document.getElementById("lng").value=location.lng;
            console.log(location);
            });
            //若服务请求失败,则运行以下函数
            geocoder.setError(function() {
                alert("出错了,请输入正确的地址!!!");
            });
        }
        codeAddress();
    </script>
</body>
</html>