Geographical positioning of HTML5 learning and html5 Geographic Positioning
Html5 coordinates:
Java code
- <! Doctype html>
- <Html>
- <Head>
- <Title> test1.html </title>
- <Meta http-equiv = "keywords" content = "keyword1, keyword2, keyword3">
- <Meta http-equiv = "description" content = "this is my page">
- <Meta http-equiv = "content-type" content = "text/html; charset = UTF-8">
- <! -- <Link rel = "stylesheet" type = "text/css" href = "./styles.css"> -->
- </Head>
- <Body>
- <Div id = "demo"> click this button to obtain your coordinates: </div>
- <Button onclick = "getLocation ()"> try it </button>
- <Script type = "text/javascript">
- Var x = document. getElementById ("demo ");
- Function getLocation (){
- If (navigator. geolocation ){
- Navigator. geolocation. getCurrentPosition (showPosition );
- } Else {
- X. innerHTML = "the browser does not support this !!! ";
- }
- }
- Function showPosition (position ){
- X. innerHTML = "Latitude:" + position. coords. latitude + "<br/> longpolling:" + position. coords. longpolling;
- }
- </Script>
- </Body>
- </Html>
After testing, the coordinates can be obtained successfully on IE9, firefox, chrome, and opera, but the coordinates cannot be returned on safari 5.x. In the successful cases, chrome responded the fastest, followed by opera, followed by IE9, and firefox was the slowest. I personally expressed my disappointment with firefox, but chrome is even better.
For the geographical positioning of html5
Go to www.html 5test.com to test your browser.
The geographical positioning functions provided by html5 can achieve precise navigation
This is difficult, but it is determined by the Communication Base Station. Generally, the error is about meters or more, and the approximate positioning should be OK.