javascript - How to access geolocation in mobile web browser - Stack Overflow

I'm used html5 geolocation I made from the documentationgetLocation() {if (navigator.geolocation)

I'm used html5 geolocation I made from the documentation

getLocation() {
   if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(this.showPosition, this.showError);
   } else {
       alert("geolocation not support");
   }
},

code working if i'm using chrome (toogle device toolbar) but in mobile browsers chrome(android) safari(ios) showing error

User did not share location

how to fix it ?

On phones geolocation enabled

UPD: Most likely this is due to the fact that there is no ssl certificate ?

I'm used html5 geolocation I made from the documentation

getLocation() {
   if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(this.showPosition, this.showError);
   } else {
       alert("geolocation not support");
   }
},

code working if i'm using chrome (toogle device toolbar) but in mobile browsers chrome(android) safari(ios) showing error

User did not share location

how to fix it ?

On phones geolocation enabled

UPD: Most likely this is due to the fact that there is no ssl certificate ?

Share Improve this question edited Apr 26, 2017 at 15:37 Rai asked Apr 25, 2017 at 15:55 RaiRai 1935 silver badges15 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2

Not all browsers have the same APIs built in. So you will have to figure out what browser a client is using and write different code depending on what APIs are included. You can figure out what browser they are using by checking the user agent.

With the latest browser updates to get geolocation, you need to use the

SSL certificates

for safari browser answer from this question helped me

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745457063a4628534.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信