如何使用HTML5地理定位或Google API取得位址的經緯度?

王林
發布: 2023-09-20 14:53:02
轉載
1527 人瀏覽過

如何使用HTML5地理定位或Google API获取地址的经纬度?

為了使用 HTML5 地理位置或任何 Google API 來取得緯度和經度,我們需要為此新增 JavaScript。

腳本如下 -

if (navigator.geolocation) {

   /*  If current position is obtained then there is success otherwise there is failure.
   On failure, separate error message is shown  */    
   navigator.geolocation.getCurrentPosition(successFunc, errorFunc);
}  else {    
   alert(‘Geolocation is not enabled in your browser. Please use a latest browser to supports it.');
}
登入後複製

以上是如何使用HTML5地理定位或Google API取得位址的經緯度?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

來源:tutorialspoint.com
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!