简体   繁体   中英

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. in JavaScript i having something like this

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.

Go to Settings > General , then go to Reset > Reset Location & Privacy .

If you intend this to be used by other users you'll have to prompt for permission like Justinas stated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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