日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

获取本浏览器经纬度坐标

發(fā)布時(shí)間:2023/12/15 综合教程 25 生活家
生活随笔 收集整理的這篇文章主要介紹了 获取本浏览器经纬度坐标 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
<!DOCTYPE html>
<html>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <body>
        <p id="demo">
            點(diǎn)擊這個(gè)按鈕,獲得您的坐標(biāo):
        </p>
        <button onclick="getLocation()">
            試一下
        </button>
        <script>
            var x = document.getElementById("demo");
            function getLocation() {
                if (navigator.geolocation) {
                    navigator.geolocation.getCurrentPosition(showPosition, showError);
                } else {
                    x.innerHTML = "Geolocation is not supported by this browser.";
                }
            }

            function showPosition(position) {
                x.innerHTML = "維度Latitude: " + position.coords.latitude + "<br />經(jīng)度Longitude: " + position.coords.longitude;
            }

            function showError(error) {
                alert('獲取經(jīng)緯度錯(cuò)誤捕獲');
                switch(error.code) {
                    case error.PERMISSION_DENIED:
                        x.innerHTML = "User denied the request for Geolocation."
                        break;
                    case error.POSITION_UNAVAILABLE:
                        x.innerHTML = "Location information is unavailable."
                        break;
                    case error.TIMEOUT:
                        x.innerHTML = "The request to get user location timed out."
                        break;
                    case error.UNKNOWN_ERROR:
                        x.innerHTML = "An unknown error occurred."
                        break;
                }
            }
        </script>
    </body>
</html>


獲取兩個(gè)坐標(biāo)之間的直線距離

// 百度地圖API功能--計(jì)算距離
var map = new BMap.Map("allmap");
var pointA = new BMap.Point( Longitude , Latitude ); // 創(chuàng)建點(diǎn)坐標(biāo)A
var pointB = new BMap.Point( Longitude , Latitude ); // 創(chuàng)建點(diǎn)坐標(biāo)B
alert('兩點(diǎn)的距離是:'+(map.getDistance(pointA,pointB)).toFixed(2)+' 米。'); //獲取兩點(diǎn)距離,保留小數(shù)點(diǎn)后兩位

查詢獲取到的經(jīng)緯度 http://www.gpsspg.com/maps.htm

百度經(jīng)緯度查詢:http://api.map.baidu.com/lbsapi/getpoint/index.html

百度官方手冊(cè) http://developer.baidu.com/map/reference/index.php

總結(jié)

以上是生活随笔為你收集整理的获取本浏览器经纬度坐标的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。