How to get the latitude and longitude of an address using HTML5 geolocation or Google API?

王林
Release: 2023-09-20 14:53:02
forward
1600 people have browsed it

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

#In order to get the latitude and longitude using HTML5 Geolocation or any Google API, we need to add JavaScript for this.

The script is as follows -

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.');
}
Copy after login

The above is the detailed content of How to get the latitude and longitude of an address using HTML5 geolocation or Google API?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!