【问题标题】:Get GPS coordinates of location获取位置的 GPS 坐标
【发布时间】:2017-03-19 05:28:54
【问题描述】:


我已经在我的项目中尝试了用于地图的 Google API。现在我需要获取用户选择的位置的 GPS 坐标,以便将其存储在 Mysql 中。

<!DOCTYPE html>
<html>
<head lang="en">
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=myKeyQ&libraries=places"></script>
<title>Demo Maps</title>
</head>
<body>
<iframe
width="600"
height="450"
frameborder="0" style="border:0"
src="https://www.google.com/maps/embed/v1/place?key=myKey
&q=Space+Needle,Seattle+WA" allowfullscreen>
</iframe>
</body>

</html>

【问题讨论】:

    标签: api google-maps google-api google-web-designer


    【解决方案1】:

    在 javascript 中,您可以使用 navigator.geolocation 功能

      <script>
        function getLocation() {
            if (navigator.geolocation) {
                navigator.geolocation.getCurrentPosition(showPosition);
            } else {
                window.alert( "Geolocation is not supported by this browser.");
            }
        }
        function showPosition(position) {
            window.alert( "Latitude: " + position.coords.latitude + 
            "<br>Longitude: " + position.coords.longitude); 
        }
    
        getLocation();
      </script>
    

    【讨论】:

    • 这是用来查找当前位置的。
    • 我想要用户选择的位置坐标;
    • 用户如何选择坐标?? ... 通过点击 ?? .我无法想象您的用户会做什么...清楚地解释...您的需求..(用户选择的 GPS 没有意义.. GPS 在您的设备内)
    猜你喜欢
    • 2016-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-18
    • 2023-03-22
    • 1970-01-01
    • 1970-01-01
    • 2014-03-27
    相关资源
    最近更新 更多