首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在php和html中使用gps显示动态路径

如何在php和html中使用gps显示动态路径
EN

Stack Overflow用户
提问于 2012-10-19 15:32:05
回答 2查看 2.4K关注 0票数 0

我正在用php和html-5开发一个网站,我的计划是在给定的JPEG图像上显示两个位置之间的动态路径,我们如何才能做到这一点,我不知道如何使用GPS系统与网站,我需要一些帮助。

谢谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-10-19 16:03:35

这里有一篇不错的文章:

http://merged.ca/iphone/html5-geolocation

代码语言:javascript
复制
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition( 

    function (position) {  

    // Did we get the position correctly?
    // alert (position.coords.latitude);

    // To see everything available in the position.coords array:
    // for (key in position.coords) {alert(key)}

    alert(position.coords.latitude + ',' + position.coords.longitude);

    }, 
    // next function is the error callback
    function (error)
    {
        switch(error.code) 
        {
            case error.TIMEOUT:
                alert ('Timeout');
                break;
            case error.POSITION_UNAVAILABLE:
                alert ('Position unavailable');
                break;
            case error.PERMISSION_DENIED:
                alert ('Permission denied');
                break;
            case error.UNKNOWN_ERROR:
                alert ('Unknown error');
                break;
        }
    }
    );
}

}

票数 0
EN

Stack Overflow用户

发布于 2012-10-19 15:51:15

查看这篇W3Schools文章:http://www.w3schools.com/html/html5_geolocation.asp

代码语言:javascript
复制
if(!navigator.geolocation){
  //the browser does not support geolocation
}else{
  (function getPosition(){
    navigator.geolocation.getCurrentPosition(
      function (position){
        //use the coordinates
        balloon.style.left = (position.coords.latitude - latMin) * latScale;
        balloon.style.top = (position.coords.longitude - longMin) * longScale;
        //requery the position after a set time
        setTimeout(getPosition,1000);
      }
    )
  })()
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12969425

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档