允许用户在特定位置输入页面

时间:2014-03-18 14:44:12

标签: php geolocation

首先在这里发帖,虽然读了一个looot ...

我是新手,我用一些地理位置撞到了墙上。

我正在为我当地的pistolshootingclub建立一个页面,整个想法是只能在实际存在的同时使用它,因为页面的主要目的是记录拍摄内容等。所以要阻止作弊者留在家里并添加没有拍摄的分数我想添加一个地理定位的东西,这样只有当一个人在场时才能使用特定的功能。

我不知道如何解决它,所以我要联系你们。我的计划是添加8个不同的lat和long来创建一个圆圈并使用< => =来确定用户是否在该圈子中。但我不能让它发生......

<script type="text/javascript>
function showlocation() {
    if (navigator.geolocation)
    {
        navigator.geolocation.getCurrentPosition(showPosition, showError);
    }
    else
    {
        alert("Geolocation is not supported by this browser.");
    }
}
function showError(error)
{
    switch (error.code)
    {
        case error.PERMISSION_DENIED:
            alert("User denied the request for Geolocation.")
            break;
        case error.POSITION_UNAVAILABLE:
            alert("Location information is unavailable.")
            break;
        case error.TIMEOUT:
            alert("The request to get user location timed out.")
            break;
        case error.UNKNOWN_ERROR:
            alert("An unknown error occurred.")
            break;
    }
}

function showPosition(pos)
{
    if (pos.coords.longitude >= 12.035540 && pos.coords.longitude <= 12.035593 &&
            pos.coords.latitude <= 57.760657 && pos.coords.latitude >= 57.759410)
    //those are the gps coordinates that i have but they are only creating a straight line
    //not a circle and if I use them alone, it, will work, sometimes depending on the        
    //reception of the unit. I tried to add 2 sets of coordinates, but then it will not at     
    //all.

    {
        window.location = 'shootingSession.php'; //if i'm at the scene, send me to this page
    } else {
        window.location = 'cheater.php'; //if i'm a cheeter, send me to the dirthole
    }
}
</script>

0 个答案:

没有答案