获得经纬度通过函数传到后台处理

来源:互联网 发布:虚拟局域网软件排行 编辑:程序博客网 时间:2024/05/16 03:45

script代码:

<script type="text/javascript">

function getLocation() {
    var result = UlyncJSLocation.getLocation();
    if (! result || result == "unknown") {
        return null;
    }
    return eval("(" + result + ")");
}

function legworkAct() {
    var location = getLocation();
    if (!location) {
        //无法登陆
        return;
    }
    var latlon = location.latitude + "," + location.longitude;
    document.getElementById("latlon").value = latlon;
    document.getElementById("legworkForm").submit();
}

</script>


java代码

<div style="display: none;">
<form id="legworkForm" method="post" action="">
    <input type="text" id = "latlon" name = "latlon" />
</form>
</div>

0 0
原创粉丝点击