简体   繁体   English

地理定位在移动浏览器 Javascript 中不起作用

[英]geolocation not working in mobile's browser Javascript

I'm currently developing a mobile web page integrated with google map, and I need to include a my location button on the google map.我目前正在开发一个与谷歌地图集成的移动网页,我需要在谷歌地图上包含一个my location按钮。 in JavaScript i having something like this在 JavaScript 我有这样的事情

navigator.geolocation.getCurrentPosition()

It is working in desktop browser, prompt me whether allot website access my location.它在桌面浏览器中工作,提示我是否分配网站访问我的位置。 In mobile browser it doesn't prompt me allow or deny, just throwing error says "User denied Geolocation".在移动浏览器中,它不会提示我允许或拒绝,只是抛出错误说“用户拒绝地理定位”。

Does anyone has come across this?有没有人遇到过这个?

So you'll have to allow location sharing on an iPhone.因此,您必须允许在 iPhone 上进行位置共享。

Go to Settings > General , then go to Reset > Reset Location & Privacy .前往Settings > General ,然后前往“ Reset > Reset Location & Privacy

If you intend this to be used by other users you'll have to prompt for permission like Justinas stated.如果您打算让其他用户使用它,则必须像 Justinas 所说的那样提示您获得许可

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM