Php html5地理位置和地址

Php html5地理位置和地址,php,mysql,html,geolocation,Php,Mysql,Html,Geolocation,我使用html5地理定位来获取我的web应用程序的lat和long。 我的问题是,如果可能的话,我需要将lat,long转换为实际地址?然后使用php将地址保存到mysql数据库。 迄今为止的代码: <p id="demo">Click the button to get your coordinates:</p> <button onclick="getLocation()">Try It</button> <script>

我使用html5地理定位来获取我的web应用程序的lat和long。 我的问题是,如果可能的话,我需要将lat,long转换为实际地址?然后使用php将地址保存到mysql数据库。 迄今为止的代码:

<p id="demo">Click the button to get your coordinates:</p>
<button onclick="getLocation()">Try It</button>
<script>
    var x = document.getElementById("demo");

    function getLocation() {
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(showPosition, showError);
        } else {
            x.innerHTML = "Geolocation is not supported by this browser.";
        }
    }

    function showPosition(position) {
        x.innerHTML = "Latitude: " + position.coords.latitude
                + "<br>Longitude: " + position.coords.longitude;
    }

    function showError(error) {
        switch (error.code) {
        case error.PERMISSION_DENIED:
            x.innerHTML = "User denied the request for Geolocation."
            break;
        case error.POSITION_UNAVAILABLE:
            x.innerHTML = "Location information is unavailable."
            break;
        case error.TIMEOUT:
            x.innerHTML = "The request to get user location timed out."
            break;
        case error.UNKNOWN_ERROR:
            x.innerHTML = "An unknown error occurred."
            break;
        }
    }
</script>

单击按钮获取您的坐标:

试试看 var x=document.getElementById(“演示”); 函数getLocation(){ if(导航器.地理位置){ navigator.geolocation.getCurrentPosition(showPosition,showError); }否则{ x、 innerHTML=“此浏览器不支持地理位置。”; } } 功能显示位置(位置){ x、 innerHTML=“纬度:”+position.coords.Latitude +“
经度:”+position.coords.Longitude; } 功能错误(错误){ 开关(错误代码){ 案例错误。权限被拒绝: x、 innerHTML=“用户拒绝了地理位置请求。” 打破 案例错误。位置不可用: x、 innerHTML=“位置信息不可用。” 打破 大小写错误。超时: x、 innerHTML=“获取用户位置的请求超时。” 打破 案例错误。未知错误: x、 innerHTML=“发生未知错误。” 打破 } }
您考虑过谷歌地图API吗?每秒和每24小时有有限的请求,因此,如果它是一个非常大的规模服务,你想提供,你可能想考虑其他事情,但与谷歌地图API的反向地理编码,你可以解决你的问题。 在这里找到它:

谢谢!它帮了我的忙!