In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use geolocation in HTML5". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how HTML5 uses geolocation".
HTML5Geolocation (geolocation) is used to locate the location of the user.
Locate the location of the user
HTML5GeolocationAPI is used to obtain the user's geographic location.
In view of the fact that this feature may infringe upon the user's privacy, the user location information is not available unless the user agrees.
Browser support
NternetExplorer9+,Firefox,Chrome,Safari and Opera support Geolocation (geolocation).
Note: Geolocation (geolocation) is more accurate for devices with GPS, such as iPhone.
HTML5- uses geolocation
Use the getCurrentPosition () method to get the location of the user.
The following example is a simple geolocation example that returns the longitude and latitude of a user's location:
Example
Var x=document.getElementById ("demo")
Function getLocation ()
{
If (navigator.geolocation)
{
Navigator.geolocation.getCurrentPosition (showPosition)
}
Else
{
X [XSS _ clean] = "this browser does not support geolocation."
}
}
Function showPosition (position)
{
X [XSS _ clean] = "Latitude:" + position.coords.latitude +
"
Longitude: "+ position.coords.longitude
}
Instance resolution:
Detect whether geolocation is supported
If supported, run the getCurrentPosition () method. If not, a message is displayed to the user.
If getCurrentPosition () runs successfully, a coordinates object is returned to the function specified in the parameter showPosition
The showPosition () function gets and displays longitude and latitude
The above example is a very basic geolocation script with no error handling.
At this point, I believe you have a deeper understanding of "how HTML5 uses geolocation". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.