Api 获取位置的GPS坐标

Api 获取位置的GPS坐标,api,google-maps,google-api,google-web-designer,Api,Google Maps,Google Api,Google Web Designer,我已经在我的项目中试用了谷歌地图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> <ti


我已经在我的项目中试用了谷歌地图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>

演示地图

在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>

函数getLocation(){
if(导航器.地理位置){
navigator.geolocation.getCurrentPosition(showPosition);
}否则{
window.alert(“此浏览器不支持地理位置”);
}
}
功能显示位置(位置){
window.alert(“纬度:+position.coords.Latitude+
“
经度:”+位置坐标经度); } getLocation();
这是为了找出当前位置。我想要用户选择的位置坐标;用户如何选择坐标。。。点击。我无法想象你的用户会做什么…清楚地解释…你的需要..(用户选择的GPS没有意义..GPS在你的设备内)