Home  >  Q&A  >  body text

javascript - How to get the current location geolocation in H5 or JS, just get the latitude and longitude

In April 2017, at the current time, how to obtain the current location geolocation through H5 or JS, all the geolocation APIs that come with H5 are not valid


Nothing happens after running the official document


You can’t get geolocation through any browser or Baidu map.


Have been personally tested and have no effect

After the pop-up window clicked Allow, there was no response

大家讲道理大家讲道理2713 days ago1032

reply all(4)I'll reply

  • PHP中文网

    PHP中文网2017-05-16 13:24:48

    The problem has been solved, I forgot to close it, now I will show it to everyone
    You must declare it first
    Introduce the corresponding js under index.html


    Then the positioning is ok, but it takes about three seconds to position on the PC browser, and the mobile 4G network is great

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-16 13:24:48

    Publish it as a domain test like (localhost/xxx/xxx.html), do not open the .html directly and browse it on the browser, it will become (file:///)
    Baidu needs to apply for an account and have its own key to ensure operation of?

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-16 13:24:48

    If you try using IE, it should show that Google is blocked.

    reply
    0
  • 天蓬老师

    天蓬老师2017-05-16 13:24:48

    http://stackoverflow.com/ques...

    The latest version of chrome needs to enable https to use geolocation

    reply
    0
  • Cancelreply