In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
In this article, the editor introduces in detail "HTML5 geolocation handling errors and rejection methods". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "HTML5 geolocation handling errors and rejection methods" can help you solve your doubts.
Handle errors and rejections
The second parameter of the getCurrentPosition () method is used to handle errors. It specifies the function to run when it fails to get the user's location:
Example
Function showError (error)
{
Switch (error.code)
{
Case error.PERMISSION_DENIED:
X [XSS _ clean] = "the user rejects the request for geolocation."
Break
Case error.POSITION_UNAVAILABLE:
X [XSS _ clean] = "location information is not available."
Break
Case error.TIMEOUT:
X [XSS _ clean] = "request user geolocation timed out."
Break
Case error.UNKNOWN_ERROR:
X [XSS _ clean] = "unknown error."
Break
}
}
Error code:
Geolocation is not allowed for Permissiondenied- users
Positionunavailable- cannot get the current location
Timeout- operation timed out
Display the results in the map
To display the results in a map, you need to access mapping services that use latitude and longitude, such as Google Maps or Baidu Maps:
Example
Function showPosition (position)
{
Var latlon=position.coords.latitude+ "," + position.coords.longitude
Var img_url= "http://maps.googleapis.com/maps/api/staticmap?center="
+ latlon+ "& zoom=14&size=400x300&sensor=false"
Document.getElementById ("mapholder") [xss_clean] = "
"
}
After reading this, the article "HTML5 geolocation handling errors and rejection methods" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.