CyLee

只能通过手机浏览器访问,并且用户必须允许访问才可以生效

<!doctype html>
<html>
  <head>
        <title>Mobile Cookbook</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
  </head>
  <body>
    <header>
    </header>
        <div id="main">
            <div id="someElm">
            </div>
        </div>
    <footer>
    </footer>
    <script src="https://cdn.bootcss.com/jquery/1.9.1/jquery.min.js"></script>
    <script>
    function getLocation() {
    navigator.geolocation.getCurrentPosition(showInfo);
  }
  function showInfo(position) {
      console.log(position);
    var latitude = position.coords.latitude;
    var longitude = position.coords.longitude;
    var accuracy = position.coords.accuracy;
    $(\'#someElm\').html(\'latitude: \'+latitude+\'<br />longitude: \'+longitude+\'<br />accuracy: \'+accuracy);
  }
  getLocation();
    </script>
    </body>
</html>

 

分类:

技术点:

相关文章:

  • 2022-02-08
  • 2021-11-21
  • 2021-12-22
  • 2021-07-27
  • 2022-02-09
  • 2022-02-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-12
  • 2021-12-10
  • 2021-11-10
相关资源
相似解决方案