ホームページ  >  記事  >  ウェブフロントエンド  >  HTML5 地理位置情報または Google API を使用して住所の緯度と経度を取得するにはどうすればよいですか?

HTML5 地理位置情報または Google API を使用して住所の緯度と経度を取得するにはどうすればよいですか?

王林
王林転載
2023-09-20 14:53:021575ブラウズ

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

#HTML5 Geolocation または 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 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事はtutorialspoint.comで複製されています。侵害がある場合は、admin@php.cn までご連絡ください。