Geographical positioning of HTML5 learning and html5 Geographic Positioning

Source: Internet
Author: User

Geographical positioning of HTML5 learning and html5 Geographic Positioning

Html5 coordinates:

Java code  
  1. <! Doctype html>
  2. <Html>
  3. <Head>
  4. <Title> test1.html </title>
  5. <Meta http-equiv = "keywords" content = "keyword1, keyword2, keyword3">
  6. <Meta http-equiv = "description" content = "this is my page">
  7. <Meta http-equiv = "content-type" content = "text/html; charset = UTF-8">
  8. <! -- <Link rel = "stylesheet" type = "text/css" href = "./styles.css"> -->
  9. </Head>
  10. <Body>
  11. <Div id = "demo"> click this button to obtain your coordinates: </div>
  12. <Button onclick = "getLocation ()"> try it </button>
  13. <Script type = "text/javascript">
  14. Var x = document. getElementById ("demo ");
  15. Function getLocation (){
  16. If (navigator. geolocation ){
  17. Navigator. geolocation. getCurrentPosition (showPosition );
  18. } Else {
  19. X. innerHTML = "the browser does not support this !!! ";
  20. }
  21. }
  22. Function showPosition (position ){
  23. X. innerHTML = "Latitude:" + position. coords. latitude + "<br/> longpolling:" + position. coords. longpolling;
  24. }
  25. </Script>
  26. </Body>
  27. </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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.