HTML5 Geolocation
HTML5 Geolocation is used to locate the user's location.
Positioning the position of the user
## HTML5 Geolocation API is used to obtain the user's geographical location.
Given that this feature may violate user privacy, user location information is not available unless the user agrees.
# browser supports
Qi test whether the browser supports:
if (navigator.geolocation) { //console.log("浏览器支持!"); }else { // console.log("浏览器不支持!"); }Navigator.Geolocation is used to obtain the current user geographical location of the browser -based, provided 3 Method:
RrreerReee Handling errors and rejection of
# stertcurrentposition () method for handling errors. It specifies the function to be run when obtaining the user's location fails: Instancevoid getCurrentPosition(onSuccess,onError,options);//获取用户当前位置 int watchCurrentPosition(onSuccess,onError,options);//持续获取当前用户位置 void clearWatch(watchId);//watchId 为watchCurrentPosition返回的值//取消监控